PDA

View Full Version : Help correcting php formatting



typaav
05-09-2006, 03:48 AM
I am trying to output data from the db through php.


echo "<div style="overflow: auto; width: 585px; height: 370px; frameborder:0"><table>";

but when i try to use a div, i receive the following error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

khendar
05-09-2006, 04:10 AM
You have to either escape the doubt quotes in the string:


echo "<div style=\"overflow: auto; width: 585px; height: 370px; frameborder:0\"><table>";

or use single quotes instead of double quotes around the string:


echo '<div style="overflow: auto; width: 585px; height: 370px; frameborder:0"><table>';

The problem is that when the parser reaches the "overflow.. part it thinks its the end of the string you are echoing, and so expects a semi-colon or comma.

degsy
05-09-2006, 01:41 PM
Or break out in to HTML if you have a lot of HTML coding.

If you are not doing so already then use an editor with snytax highlighting. It will help with strings and quotes.