Fearpig Posted August 10, 2006 Share Posted August 10, 2006 Hi Guys,Can anyone help me with the following?I'm trying to set up a PHP page where you can edit data stored in an SQL table. Here's my 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"] ?>"><br> <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>The page before passes through the 'id' variable and this page should populate three text boxes with the values stored in the database. The problem is that when I get to this page the textboxes only have the following error message: <br /><b>Notice</b>: Undefined variable: myrow in <b>D:\Intranet v3\php_Telephone_List\Edit_SpecificPerson.php</b> on line <b>17</b><br />With a different line in each textbox (lines 15, 16 and 17). If anyone can spot where I'm going wrong I'd be very grateful.CheersTom Link to comment https://forums.phpfreaks.com/topic/17116-edit-database-through-php/ Share on other sites More sharing options...
onlyican Posted August 10, 2006 Share Posted August 10, 2006 I just copied that code and pasted DWCommented out the MySQL Queries ectSavedNo problems, no errors no nothing Link to comment https://forums.phpfreaks.com/topic/17116-edit-database-through-php/#findComment-72393 Share on other sites More sharing options...
Fearpig Posted August 10, 2006 Author Share Posted August 10, 2006 I'm sorry... I don't understand.... ???Could you repost the code and show me how you got no errors. Link to comment https://forums.phpfreaks.com/topic/17116-edit-database-through-php/#findComment-72400 Share on other sites More sharing options...
redarrow Posted August 10, 2006 Share Posted August 10, 2006 all i see no while loop?[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);while($myrow=mysql_fetch_assoc($result)){?><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] Link to comment https://forums.phpfreaks.com/topic/17116-edit-database-through-php/#findComment-72402 Share on other sites More sharing options...
Silverado_NL Posted August 10, 2006 Share Posted August 10, 2006 i think you should declare the $my_row variable first.and intead of putting the database info in the $result variable you could put it in the $my_row variable Link to comment https://forums.phpfreaks.com/topic/17116-edit-database-through-php/#findComment-72404 Share on other sites More sharing options...
Fearpig Posted August 10, 2006 Author Share Posted August 10, 2006 Doh!Thank you guys I think the process of writing it out again unblocked something and I managed to work it out. It was that I was just missing the line:$myrow = mysql_fetch_array($result)Which should be at the start where I declare my variables.Cheers for your help. Link to comment https://forums.phpfreaks.com/topic/17116-edit-database-through-php/#findComment-72409 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.