...

View Full Version : Retrieve data from database



cooly291
06-11-2006, 06:09 AM
Hi, I am having a problem with getting the data from my database to appear the way I want it to, it appears just fine in the following form:



echo "
<p>
<strong>Name:</strong> $ac_name<br />\n
<strong>Friend Code:</strong> $friend_code<br />\n
<strong>Native Fruit:</strong> $native_fruit<br />\n
<strong>Comments:</strong> $comments
</p>
";
}


However, when I put it in this form:



echo "
<table width="60%"><tr><td width="15">
AC Name
</td>
<td width="15%">
Friend Code
</td>
<td width="15%">
Native Fruit
</td>
<td width="15%">
Comments
</td>
</tr>
<td width="15%">
$ac_name
</td>
<td width="15%">
$friend_code
</td>
<td width="15%">
$native_fruit
</td>
<td width="15%">
$comments
</td>
</tr>
</table>
";
}


I get the error



Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in /home/zeldalin/public_html/form/display_data.php on line 14


Any suggestions?

FishMonger
06-11-2006, 08:29 AM
This is really a php issue, not MySQL.

I'm not an expert in php, but I'd say the issue is due to your quoting. Try escaping the double quotes within the statement, or use single quotes.


echo "
<table width='60%'><tr><td width='15'>
AC Name
</td>
<td width='15%'>
Friend Code
</td>
<td width='15%'>
Native Fruit
</td>
<td width='15%'>
Comments
</td>
</tr>
<td width='15%'>
$ac_name
</td>
<td width='15%'>
$friend_code
</td>
<td width='15%'>
$native_fruit
</td>
<td width='15%'>
$comments
</td>
</tr>
</table>
";
}

raf
06-11-2006, 03:05 PM
it's indeed a PHP error, but you best either escape double quotes in a double-quoted string, or use a single-quoted string so that the echoed html is valid. like


echo '
<table width="60%"><tr><td width="15">
AC Name
</td>
<td width="15%">
Friend Code
</td>
<td width="15%">
Native Fruit
</td>
<td width="15%">
Comments
</td>
</tr>
<td width="15%">',
$ac_name ,'
</td>
<td width="15%">',
$friend_code ,'
</td>
<td width="15%">',
$native_fruit ,'
</td>
<td width="15%">',
$comments ,'
</td>
</tr>
</table>
';
}

cooly291
06-11-2006, 06:44 PM
blah, I knew that >_<

Thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum