1

New to PHP and changed some code further down than line 1 on a WordPress site. Using Dreamweaver CC to upload. Getting:

Parse error: syntax error, unexpected T_IF in /home/jodyrein/public_html/www.writersblogfinder.com/wp-content/themes/rockthebook/functions.php on line 1

at www.writersblogfinder.com

Here is the first few lines of code:

<?php
/**
 * rockthebook functions and definitions
 *
 * @package rockthebook
 */

/**
 * Set the content width based on the theme's design and stylesheet.
 */
if ( ! isset( $content_width ) )
    $content_width = 640; /* pixels */
4
  • Try hitting Enter after the php tag. Commented Nov 24, 2013 at 18:38
  • Thanks but that didn't work. Commented Nov 24, 2013 at 18:43
  • Remove all the comments. Commented Nov 24, 2013 at 18:45
  • Well now I've noticed when I download the file all the code is on one line: <?php/** * rockthebook functions and definitions * * @package rockthebook //* * Set the content width based on the theme's design and stylesheet. /if ( ! isset( $content_width ) ) $content_width = 640; / pixels /if ( ! function_exists( 'rockthebook_setup' ) ) :/* * Sets up theme defaults and registers support for various WordPress features. Commented Nov 24, 2013 at 18:56

5 Answers 5

0

Check that you have not edited your file using a horrible editor, like notepad. Your if() statement is reported as line 1, prrobably because of the lineends. Save the file in another editor, that uses newline instead or carriage return.

Sign up to request clarification or add additional context in comments.

Comments

0

I've had similar problems before with hidden/non standard characters creeping into the file thanks to bugs / quirks in the editor. Best thing to do - copy the whole lot of the code into something like notepad (PC) or textmate (mac) and save the file out again, re-upload and re-test it... usually resolves it for me.

3 Comments

Notepad is probably a culprit. Wordpad on Windows works better.
I may be out of touch as not used Windows regularly for a long time - but Wordpad used to be a rich text editor versus notepad being plain text... is that no longer the case?
Thanks, I didn't write all the code and was making some changes (further along) when that happened; trying to get the original code back; unfortunately I didn't back it up, bad me.
0

Seems Dreamweaver was loading the php text all as one line. I pasted the php into the Wordpress editor and and it's fine

Comments

0

copying to Notepad editor saving and uploading fixed my problem.

Comments

-1

I just wanted to mention after hours of trying to figure this out, re-saving from Notepad worked!

I use Sublime Text 3 as my daily text editor, so I find it quite odd that this issue wasn't being picked up, but copying the code from ST3, pasting in to Notepad and then saving over functions.php fixed the error.

I should also note that I was only seeing this error on the server, not on my localhost.

Thank you for this advice!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.