I am trying to insert table data into listbox. It is giving following error. Parse error: syntax error, unexpected T_STRING in /home/sanganak/public_html/rajiv2/listbox_category.php on line 23 My code is this - <body> <?php $con = mysql_connect("localhost","sanganak_manish","manish"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("sanganak_mydata",$con); $result = mysql_query("SELECT * FROM category); ?> ERROR <p align="center" class="style1">Edit/Delete Category </p> <table width="100%" border="0"> <form method="post" action="edit_delete_category.php"> <tr> <td width="12%"> </td> <td width="26%">Name of Category </td> <td width="14%"> <?php echo '<select name="category">'; while($row = mysql_fetch_array($result)) { echo "<option value='".$row['category']."'>'."$row['category']".'</option> "; } echo "</select>";?> ?> </td> <td width="36%"><input name="edit" type="submit" id="edit" value="Edit"> <input name="delete" type="submit" id="delete" value="Delete"></td> <td width="6%"> </td> <td width="6%"> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </form> </table> <p align="center" class="style1"> </p> </body> Please solve my error.
On line 23, replace with this proper syntax echo "<option value='".$row['category']."'>".$row['category']."</option>"; PHP:
$result = mysql_query("SELECT * FROM category); should be $result = mysql_query("SELECT * FROM category"); The line number is not always correct due to how PHP parses.