Fearpig Posted August 4, 2006 Share Posted August 4, 2006 Hello guys, Can someone take a look at my code and point me in the right direction? I'm reading through various tutorials on the web and trying to make my own pages to edit data in a MySQL database. The page before this one brings up a list of names and when the user clicks on one it opens the page below with a variable called "id" specifying which record to show.[b]<?php$db = mysql_connect("localhost", "root", "password");$id = $_GET['id'];mysql_select_db("Telephonelist",$db);$result = mysql_query("SELECT * FROM tbl_telephonenumbers WHERE ID=$id",$db);<form action="Submit_SpecificPerson.php" method="post"><INPUT TYPE="HIDDEN" NAME="ID" VALUE="<?php echo $myrow["ID"] ?>"> <INPUT TYPE="TEXT" NAME="First_Name" VALUE="<?php echo $myrow["First_Name"] ?>" SIZE=30><br><INPUT TYPE="TEXT" NAME="Last_Name" VALUE="<?php echo $myrow["Last_Name"] ?>" SIZE=30><br><INPUT TYPE="TEXT" NAME="Role" VALUE="<?php echo $myrow["Role"] ?>" SIZE=30><br><input type="Submit" value="Update"></form>?>[/b]When I run this page I get the following error:Parse error: parse error, unexpected '<' in D:\Intranet v3\php_Telephone_List\Edit_SpecificPerson.php on line 16 [b]line 16 is the line beginnning "<form action=......."[/b]Any help with this would be greatly appreciated as I'm just stuck at the moment!Cheers. Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 4, 2006 Share Posted August 4, 2006 You 'closed' the php section in the wrong place. Try this:[code]<?php$db = mysql_connect("localhost", "root", "password");$id = $_GET['id'];mysql_select_db("Telephonelist",$db);$result = mysql_query("SELECT * FROM tbl_telephonenumbers WHERE ID=$id",$db);?><form action="Submit_SpecificPerson.php" method="post"><INPUT TYPE="HIDDEN" NAME="ID" VALUE="<?php echo $myrow["ID"] ?>"> <INPUT TYPE="TEXT" NAME="First_Name" VALUE="<?php echo $myrow["First_Name"] ?>" SIZE=30><INPUT TYPE="TEXT" NAME="Last_Name" VALUE="<?php echo $myrow["Last_Name"] ?>" SIZE=30><INPUT TYPE="TEXT" NAME="Role" VALUE="<?php echo $myrow["Role"] ?>" SIZE=30><input type="Submit" value="Update"></form>[/code] Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 4, 2006 Share Posted August 4, 2006 also, $id needs to be in single quotes[code=php:0]$result = mysql_query("SELECT * FROM tbl_telephonenumbers WHERE id = '".$id."'");[/code](Dont need the link identifier if its the only connection)(Just makes the code look cleaner escaping out of the string for vars, nothing more) Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted August 4, 2006 Share Posted August 4, 2006 The variable [b]$id[/b] only needs to be in quotes if it is not defined as a number in the DB.Ken Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 4, 2006 Share Posted August 4, 2006 who the F told you thatI have a table, called prodsand a column called nameIf I run a query in MySQL-FrontSELECT * FROM prods WHERE name = Product;Then I get errorUnknown Column Product in WHere ClauseIf I Run QuerySELECT * FROM prods WHERE name = 'Product';I get the result Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.