WordPress.org

Ready to get started?Download WordPress

Forums

Parse error: syntax error (4 posts)

  1. montymcmahon
    Member
    Posted 3 months ago #

    I just made a small update to a .php file that broke the whole site. I got this error message.

    Parse error: syntax error, unexpected ':' in /home/avchirop/public_html/wp-content/themes/wp_medi5-v1.0/panel/generic.php on line 478

    This is the code on that line of the file:

    $text = preg_replace('/:year:/', date('Y'), $text);

    Odd thing is I didn't even change anything on that line.

    Also odd, I installed a backup of the file and that still didn't fix the problem.

    Can anyone tell me what's going on here?

  2. catacaustic
    Member
    Posted 3 months ago #

    Did you change a line above it somewhere? The times that I've seen that error before is when I've forgotten to add a closing ' somewhere and it's bubbled down the code until it's found the next ' and used that one.

    What text editor are you using? If you're not already I'd realyl suggest that you use one that does syntax highliting. That lets you see errors a whole lot easier, and will help to see just where problems like this are really happening.

  3. montymcmahon
    Member
    Posted 3 months ago #

    I did change a line above it. I ultimately restored a backup file, edited it again and it worked fine.

    I was doing all of this in TextEdit. Do you have any suggestions on something that lets you see syntax errors as described?

    Editing .php is not my forte. Just figuring it out as I go along.

  4. catacaustic
    Member
    Posted 3 months ago #

    For editing I use a free program called Komodo Edit. There's a paid version that's a full IDE, but I haven't found the need for that yet, and I wouldn't suggest that you pay for the full version yet either. Get to know it and see how you feel. There's a lot of other programs out there too, and it may take some time to find one that suits you and the way that you want to work.

Reply

You must log in to post.

About this Topic