php generates an error on parsing accross a space
Posted by: mkiiru (197.179.2.---)
Date: September 15, 2012 08:22PM

Hi all,

I am a straight newbie to the WAMP Server. running Apache Version :2.2.6 and PHP Version :5.2.5 on Windows 7 enterprise.

in my hello world, the parser generates an error when I echo a string with spaces say like when I have a space between hello and world, if I join them up to "helloworld" everything runs ok... what would the cause be?

Mike.

Options: ReplyQuote
Re: php generates an error on parsing accross a space
Posted by: stevenmartin99 (Moderator)
Date: September 15, 2012 08:25PM

paste the code,

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: php generates an error on parsing accross a space
Posted by: mkiiru (197.179.2.---)
Date: September 15, 2012 09:08PM

This is the code am running...

<html>
<head>
<title>My First PHP Script</title>
</head>
<body>
<p>Yipeeeee!! it works!</p>
<?php
echo “This_is_PHP”;
?> <p>
<?php
echo “PheeewYehee”;
?>
</body>
</html>

Options: ReplyQuote
Re: php generates an error on parsing accross a space
Posted by: stevenmartin99 (Moderator)
Date: September 15, 2012 09:11PM

this code fails?

and paste the error

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: php generates an error on parsing accross a space
Posted by: mkiiru (197.179.2.---)
Date: September 15, 2012 09:21PM

Please take note of the error posted when I put a space between Pheeew & Yehee

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\wamp\www\HelloWorld\index.php on line 11

Options: ReplyQuote
Re: php generates an error on parsing accross a space
Posted by: stevenmartin99 (Moderator)
Date: September 15, 2012 09:26PM

your quotes are wrong

they should be " " not “ ”

use a good file editor like notepad++

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: php generates an error on parsing accross a space
Posted by: mkiiru (197.179.2.---)
Date: September 15, 2012 09:44PM

Steven,

How on earth was I suppposed to know the difference between the two characters (by the way what is the ascii code for each of the two?) I use the same key only that the editor is different!!

Thank you soo much for the speedy response which has drawn me closer to writing more scripts in php... as IT WORKS! smiling smiley

Gracias.

Options: ReplyQuote
Re: php generates an error on parsing accross a space
Posted by: stevenmartin99 (Moderator)
Date: September 15, 2012 09:54PM

you need to set the char encoding at the top of the editor

The standard double quote is " which is ASCII (2)


The opening and closing double quotes “ ” are not part of ASCII at all , they are Unicode chars.
These are generally used for typing novels, books etc, for languages


Even if your editor is set to unicode( which is fine) the standard double qoute is part of it , so maybe your keyboard is not setup right for the language?

shift + 2 in UK layout and Shift + ' in US layout


Honestly just using an editor designed for programming languages like notepad++ and set the Encoding to ANSI

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]



Edited 1 time(s). Last edit at 09/15/2012 09:55PM by stevenmartin99.

Options: ReplyQuote
Re: php generates an error on parsing accross a space
Posted by: mkiiru (197.179.2.---)
Date: September 15, 2012 10:09PM

Thanks stevens for the elaborate response... You have assisted a brother.

hav a lovely ere night. (its 2309hr EAT here winking smiley)

Options: ReplyQuote


Sorry, only registered users may post in this forum.