Copying php script from book and get error

Closed
nikkon - Feb 10, 2015 at 06:57 PM
 nikkon - Feb 11, 2015 at 04:57 PM
Hello,

I m recently started to study php

I m copying the example script from the ebook but I get the following error

Parse error: syntax error, unexpected 'have' (T_STRING), expecting ',' or ';' in C:\wamp\www\1.php on line 6

script is

?php

$widgets = 23;
if ( $widgets == 23 ) {
echo "We have exactly 23 widgets in stock!";

}
?>


also with other similar scripts I get parse errors too. Where is the problem?

Thanks

1 response

Blocked Profile
Feb 10, 2015 at 07:39 PM
Did you open the script with "<"?

I found the Ebook with your example in it, on page 52.

Even though I write ASP, it is pretty much is same syntax. Based on what you have posted, he only thing missing is your first "<".

If not, then please post more, and we will take a look!
0
<?php

$widgets = 23;
if ( $widgets == 23 ) {
echo "We have exactly 23 widgets in stock!";

}
?>

This is the script. I had already put the " < " sign.
Don't know what is going on.
Suggest for you to try it also

Anyway thanks for your remark
0
I got it finally!

It has to do with copying script from pdf fie.
Also copying from word document it gives errors.
Typing the script is ok!
Now I m wondering how can I copy it for saving time!
0
Blocked Profile
Feb 11, 2015 at 01:11 PM
Paste it into a note pad first. Then cut and copy from there. Notepad has no formatting overhead that you were experiencing with the other cut and paste. Please do your self a favor and do not get used to cut and pasting. You will spend your development time trying to find errors n others code.
0
nikkon > Blocked Profile
Feb 11, 2015 at 04:57 PM
Thanks a lot for your advice
FYI it gives error also with cut and paste from notepad.

Thanks again anyway!
0