unexpected T_ENCAPSED_AND_WHITESPACE?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rbroadwe
Forum Newbie
Posts: 10
Joined: Wed May 06, 2009 5:18 pm

unexpected T_ENCAPSED_AND_WHITESPACE?

Post by rbroadwe »

Code: Select all

 
if( $num_rows != 0 )
{
    while($row = mysql_fetch_array($result))
    {
        echo $row['time'] . " " . $row['ampm'];
        echo "&nbsp;<a href='schedule_now.php?appt_id=$row['appt_id']'>&nbsp;Schedule Now!&nbsp;</a>";
        echo "<br />";
    }
}
 
generates error
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/robbroa1/public_html/thefixitfox/check_appt.php on line 261
row 261 corresponds to row 7.

I don't understand this... anyone have any ideas?

Thank you!
Last edited by Benjamin on Sat May 16, 2009 10:02 am, edited 1 time in total.
Reason: Changed code type from text to php.
Griven
Forum Contributor
Posts: 165
Joined: Sat May 09, 2009 8:23 pm

Re: unexpected T_ENCAPSED_AND_WHITESPACE?

Post by Griven »

Use concatenation in this case.

I don't know the precise reason why it's throwing the error, but I tested it out, and this line will work:

Code: Select all

echo "&nbsp;<a href='schedule_now.php?appt_id=". $row['appt_id'] ."'>&nbsp;Schedule Now!&nbsp;</a>";
rbroadwe
Forum Newbie
Posts: 10
Joined: Wed May 06, 2009 5:18 pm

Re: unexpected T_ENCAPSED_AND_WHITESPACE?

Post by rbroadwe »

fixed it. :D thank you!!!
Post Reply