Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-11-2006, 05:09 AM   PM User | #1
cooly291
New Coder

 
Join Date: Jan 2005
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
cooly291 is an unknown quantity at this point
Retrieve data from database

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:

Code:
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:

Code:
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

Code:
Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in /home/zeldalin/public_html/form/display_data.php on line 14
Any suggestions?
cooly291 is offline   Reply With Quote
Old 06-11-2006, 07:29 AM   PM User | #2
FishMonger
Super Moderator


 
Join Date: May 2005
Location: Southern tip of Silicon Valley
Posts: 2,757
Thanks: 2
Thanked 149 Times in 144 Posts
FishMonger will become famous soon enoughFishMonger will become famous soon enough
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.

Code:
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>
";
}
FishMonger is offline   Reply With Quote
Old 06-11-2006, 02:05 PM   PM User | #3
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf will become famous soon enoughraf will become famous soon enough
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
PHP Code:
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>
'
;

__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Old 06-11-2006, 05:44 PM   PM User | #4
cooly291
New Coder

 
Join Date: Jan 2005
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
cooly291 is an unknown quantity at this point
blah, I knew that >_<

Thanks!
cooly291 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:02 AM.


Advertisement
Log in to turn off these ads.