adap Posted January 16, 2010 Share Posted January 16, 2010 $db_user = 'root'; $db_pwd = ''; $database = 'sk39_properties'; $table = 'properties'; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); $sql = "select * from 'Properties' where id = 1"; $query = mysql_query($sql); while ($row = mysql_fetch_array($query)){ $id = $row['id']; $Furnishing = $row['Furnishing']; $Address = $row['Address']; $Tenure = $row['Tenure']; } mysql_free_result($query); ?> <html> <head> <title>Edit User Info</title> </head> <body> <form action="updateinfo.php" method="post"> Id:<br/> <input type="text" value="<?php echo $id;?>" name="id" disabled/> <br/> Furnishing:<br/> <input type="text" value="<?php echo $Furnishing;?>" name="Furnishing"/> <br /> Address:<br/> <input type="text" value="<?php echo $Address;?>" name="Address"/> <br /> Tenure:<br/> <input type="text" value="<?php echo $Tenure;?>" name="Tenure"/> </br> <input type="submit" value="submit changes"/> </form> </body> </html> Above is my code. When running it, it came out the following error Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\editinfo.php on line 18 Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\editinfo.php on line 25 Id: Furnishing: <br /> <b>Notice</b>: Undefined variable: Furnishing in <b>C:\wamp\www\editinfo.php</b> on line <b>45</b><br /> Address: <br /> <b>Notice</b>: Undefined variable: Address in <b>C:\wamp\www\editinfo.php</b> on line <b>50</b><br /> Tenure: <br /> <b>Notice</b>: Undefined variable: Tenure in <b>C:\wamp\www\editinfo.php</b> on line <b>55</b><br /> Anyone can help!? :'( Quote Link to comment Share on other sites More sharing options...
Buddski Posted January 16, 2010 Share Posted January 16, 2010 Your last 3 errors are because of the fetch_array error.. $query = mysql_query($sql) or trigger_error(mysql_error()); it will tell you if the SQL is working correctly.. And after looking at the query.. $sql = "select * from 'Properties' where id = 1"; should be $sql = "select * from `Properties` where id = 1"; Quote Link to comment Share on other sites More sharing options...
adap Posted January 16, 2010 Author Share Posted January 16, 2010 Thanks. It fixed. By the way, would like to ask. If i wish to slightly change it. This is how it works. First, a php to prompt the user to change any of the data inside the table by key in the id which is the primary key. After choosing it, it will link to another php file which serve like how the above php code that i posted. From there, only they submit changes to it. Any advise or enlighten? 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.