PHP Parse Error

I am trying to have a query result set populate a table. This part works fine. The part I cant figure out is how to get a button to pop at the beginning of each row so i can select a specific record. The solution I am trying is to go with a form containing a hidden input variable which gets set to the ID of the table row. and a button to select a record.

I am getting the following syntax error on the line where i declare the form.

Parse error: syntax error, unexpected T_STRING, expecting ‘,’ or ‘;’

Obviously I have typed something wrong but im not sure what.

[php]
//output the response
echo “<table alingn=“center” width=“400px;”>”;
echo "


ID
FirstName
LastName
";
while ($row = mysql_fetch_assoc($result)){
echo "






“.$row[‘FName’].”
“.$row[‘LName’].”
";
}
		echo "</table>";   

[/php]

[php]
echo "








“.$row[‘FName’].”
“.$row[‘LName’].”
";
[/php]

There are multiple quotes here that need Escaping. Here’s a tidy-up:

[php]
echo "



<form id="{$row[‘ID’]}" name="{$row[‘ID’]}" method=“post” action=“p_select.php”>
<input type=“hidden” name=“PID” value="{$row[‘ID’]}"/>
<input type=“submit” value=“Submit”/>


{$row[‘FName’]}
{$row[‘LName’]}
";
[/php]

Also:
echo “<table alingn=“center” width=“400px;”>”;

Should be
[php]
echo “<table align=“center” width=“400px”>”;
[/php]

Look at the colouring around the input attributes in the code on your post or in my re-post below. Using an IDE such as NetBeans to code will show you errors such as this (as will Notepad++ if you make sure you set the language to PHP once installed for your files).

[php]
echo "








“.$row[‘FName’].”
“.$row[‘LName’].”
";
[/php]

Anyway, basically your issue is the speech marks around the input attributes - either change the echo (including all concatenations) to use single speech marks (apostrophes ’ ) or replace the speech marks which should be echoed (rather than treated as a string termination) such as in type=“hidden” with their ‘escaped’ version. This would make my previous example:

[php]echo “<input type=“hidden” />”;[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service