Forum Moderators: coopster

Message Too Old, No Replies

Parse error, unexpected T_VARIABLE

Some help with my first php code.

         

supersword

6:33 pm on Sep 7, 2005 (gmt 0)

10+ Year Member



Ok, brand new to php. I bought the teach yourself php book and it is really good. I just tried to get my first bit of code working and guess what, it didn't.

Here is my code.

<?
$name = "Sam" ;
echo "Hello, my name is $name. This is my first example of working with php <br/>"
$time = "Seven twenty two" ;
echo "The time is $time <br/>" ;
?>

See, something simple. I basically tried to make my name and the time a $variable and use it in a sentence.

Now when I put it on my server, I get this error.

Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in /home/sammart/public_html/index.php on line 4

So I look on line 4 for something strange, and I can't see anything wrong.

Thanks for any help,
Sam

jatar_k

6:40 pm on Sep 7, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld supersword,

the second line is missing a semi colon at the end

I couldn't see it either, took me a min or two ;)

since the line is not terminated properly the error drops through to the next line because the parser thinks it is all one line

supersword

6:44 pm on Sep 7, 2005 (gmt 0)

10+ Year Member



:) Your a hero. Thanks for the speedy reply and im sure I will be using the forums often now.

Thanks,
Sam

jatar_k

6:53 pm on Sep 7, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> I will be using the forums often now

glad to hear it, we always like a fresh perspective and new additions