Forum Moderators: coopster

Message Too Old, No Replies

Using single quote to echo html tags

         

fib_81

5:59 pm on Mar 28, 2005 (gmt 0)

10+ Year Member



Hi All,

I am getting a parse error, saying Parse error: parse error, expecting `','' or `';''

This is the part of the code:

echo "<table cellpadding=0 cellspacing=0>";
echo " <tr>";
echo "<td><input type=checkbox name=\"check_sun[]\" value="1">";

The line that is getting an error is
echo "<td><input type=checkbox name=\"check_sun[]\" value="1">"; .

I thought having double quotes was ok and apparently it was not. Using single quotes eliminated the parsing error and I was wondering why this was the case?

Regards,
Fib_81

brendan3eb

6:32 pm on Mar 28, 2005 (gmt 0)

10+ Year Member



you forgot to add backslashes before the double quotes in value=1. The below code should work using doublequotes:

echo "<td><input type=checkbox name=\"check_sun[]\" value=\"1\">";

Longhaired Genius

6:32 pm on Mar 28, 2005 (gmt 0)

10+ Year Member



In your example, you didn't escape the final pair of double quotes.

fib_81

8:53 pm on Mar 28, 2005 (gmt 0)

10+ Year Member



Hi,

Thanks for all those who helped. I finally got it to work with double quotes. Thanks again for those who helped.

Thank you,
Fib_81

gettopreacherman

3:20 am on Mar 30, 2005 (gmt 0)

10+ Year Member



When doing large quantities of html in a form with php, i do a single quote then paste the html...this allows you to not have to worry about the double quotes...like:

echo '<table cellpadding=0 cellspacing=0>
<tr>
<td><input type=checkbox name="check_sun[]" value="1">';

Give it a try...you'll find it's mighty useful...:-)