uaeustudent Posted May 29, 2007 Share Posted May 29, 2007 I have this code for dislpay information (by the id of the user) was stored in the database but it give an error and I think it from this line $id = $_GET['id']; $query = "SELECT * FROM $table WHERE id='$id'LIMIT 1"; And this my code: ]<html> <head> <title>Title here!</title> </head> <body> <?php $host = "localhost"; $user = ""; $password = ""; $db = "Job seeker"; $table = "personalinformation"; mysql_connect($host,$user,$password) or die("Failed to connect"); mysql_select_db($db) or die("Falied to select database"); $id = $_GET['id']; $query = "SELECT * FROM $table WHERE id='$id'LIMIT 1"; //$query = "SELECT * FROM $table WHERE id='$id' LIMIT 1"; $result = mysql_query($query) or die("problem with query: ".$query); $row = mysql_fetch_array($result); if ($row){ // echo "<td><td><tr>$myrow[id]</tr><tr>$myrow[Address]</tr><tr>$myrow[City]</tr><tr>$myrow[Fax]</tr><tr>$myrow[specialization]</tr><tr>$myrow[TargetSalary]</tr><tr>$myrow[JobType]</tr><tr>$myrow[WillingToRelocate]</tr></td></td>" ; } else { echo "mysql Error: " . mysql_error(); } ?> <h3> Personal Information form</h3> <table border=1> <tr> <td>id</td> <td><?=$row['id'];?></td> </tr> <tr> <td>Address</td> <td><?=$row['Address'];?></td> </tr> <tr> <td>City</td> <td><?=$row['City'];?></td> </tr> <tr> <td>Fax</td> <td><?=$row['Fax'];?> </td> </tr> <tr> <td>Specialization</td> <td><?=$row['Specialization'];?></td> </tr> <tr> <td>TargetSalary</td> <td><?=$row['TargetSalary'];?></td> </tr> <tr> <td>JobType</td> <td><?=$row['JobType'];?></td> </tr> <tr> <td>WillingToRelocate</td> <td><?=$row['WillingToRelocate'];?> </td> </tr> </table> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/53442-mysql-error/ Share on other sites More sharing options...
eric1235711 Posted May 29, 2007 Share Posted May 29, 2007 what the error message tells? Quote Link to comment https://forums.phpfreaks.com/topic/53442-mysql-error/#findComment-264075 Share on other sites More sharing options...
uaeustudent Posted May 29, 2007 Author Share Posted May 29, 2007 It display mysql Error: Quote Link to comment https://forums.phpfreaks.com/topic/53442-mysql-error/#findComment-264126 Share on other sites More sharing options...
wildteen88 Posted May 29, 2007 Share Posted May 29, 2007 Chnage this: query = "SELECT * FROM $table WHERE id='$id'LIMIT 1"; //$query = "SELECT * FROM $table WHERE id='$id' LIMIT 1"; $result = mysql_query($query) or die("problem with query: ".$query); $row = mysql_fetch_array($result); if ($row){ // echo "<td><td><tr>$myrow[id]</tr><tr>$myrow[Address]</tr><tr>$myrow[City]</tr><tr>$myrow[Fax]</tr><tr>$myrow[specialization]</tr><tr>$myrow[TargetSalary]</tr><tr>$myrow[JobType]</tr><tr>$myrow[WillingToRelocate]</tr></td></td>" ; } else { echo "mysql Error: " . mysql_error(); } to this: $query = "SELECT * FROM $table WHERE id='$id'LIMIT 1"; //$query = "SELECT * FROM $table WHERE id='$id' LIMIT 1"; $result = mysql_query($query) or die('problem with query: ' . $query . '<br />' . mysql_error()); if(mysql_num_rows($result) == 1) { $row = mysql_fetch_array($result); echo "\n<tr> <td>{$myrow['id']}</td> <td>{$myrow['Address']}</td> <td>{$myrow['City']}</td> <td>{$myrow['Fax']}</td> <td>{$myrow['Specialization']}</td> <td>{$myrow['TargetSalary']}</td> <td>{$myrow['JobType']}</td> <td>{$myrow['WillingToRelocate']}</td> </tr>\n"; } else { echo 'No results returned'; } Quote Link to comment https://forums.phpfreaks.com/topic/53442-mysql-error/#findComment-264225 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.