Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 13th, 2005, 10:31 PM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to elania
Default Help detect error

i keep on getting this error message:
Parse error: parse error, expecting `','' or `';'' in c:\apache\htdocs\labms\member_search_process1.php on line 54

line 54:
echo "<td width="100"><div align="center"><strong>$username</strong></div></td>\n";

can anyone tell me what's wrong with this? did i miss anything?


i'm am total newbie
__________________
i\'m am total newbie
 
Old February 14th, 2005, 01:31 AM
Authorized User
 
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you have to escape all of your " .try this:

echo '<td width="100"><div align="center"><strong>';
echo $username;
echo '</strong></div></td>\\n';

OR do this:
echo "<td width=\"100\"><div align=\"center\"><strong>$username</strong></div></td>\\n";


----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
 
Old February 14th, 2005, 04:04 AM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to elania
Default

thanks Gotaka4. it works.

but i don't understand what does <<<you have to escape all of your ">>> means?

why do i need to put \"100\" ?

i'm am total newbie
 
Old February 14th, 2005, 12:39 PM
Authorized User
 
Join Date: Jan 2005
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you can enclose strings either between ' ' or between " "; so the following is equal.

echo 'This is a string';
echo "This is a string";

the only difference between the two is that strings a between the double quotations (" ") are evaluated. so if you had a stuck a variable between the double quotes, it would read the value of the variable: e.g.

$some_var = "this is another string";

echo "Here is a string and $some_var";
prints //here is a string and this is another string

but if you had. Notice the single quote.

echo 'Here is a string and $some_var';
prints //Here is a string and $some_var;

because anything between single quote is regarded as string and is not evaluated by PHP. So if you know you have nothing but string, it is recommended to use the single quote as it is faster than double quotes.

----------so now to your question.
why would you escape your double quotes. Think about this line of quote for one sec:

echo "<td width="100">.......";

what PHP sees is that it is supposed to print (aka echo) the string between the double quotes which would be "<td width="

There are two things wrong here:
the statement echo is not terminated with the semi-colon ; .
and 100 is left out in the open. PHP has no idea where it came from and what it is.

to avoid this, you have to escape the double quotes that you want PHP to consider as plain string.


----------------
Never bother to learn something not knowing which does not do you any harm, and never neglect to learn something whose negligence will increase your ignorance - Imam Jafar Sadeq
 
Old February 14th, 2005, 09:55 PM
Authorized User
 
Join Date: Jan 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to elania
Default

now i get it. thanks Gotaka4 for making it clear for me.

i'm am total newbie





Similar Threads
Thread Thread Starter Forum Replies Last Post
Detect associated label ysiline Access VBA 1 April 26th, 2006 07:16 AM
Detect Number zaeem Classic ASP Databases 1 December 1st, 2003 03:02 AM
Flash detect Adam H-W Javascript 4 October 30th, 2003 08:00 AM
Detect MDAC dunnie VB How-To 8 July 17th, 2003 03:09 PM
Flash detect Adam H-W Flash (all versions) 1 June 18th, 2003 08:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.