savagenoob Posted December 19, 2008 Share Posted December 19, 2008 I am having a hell of a time getting my MySql table to display... Here is the code... <?php // load the configuration file. mysql_connect("localhost","root","xxxxxx"); //select which database you want to edit mysql_select_db("database"); $result = mysql_query("SELECT * FROM clients ORDER BY ID",$connect); while($myrow = mysql_fetch_assoc($result)) {//begin of loop //now print the results: echo "<b>Policy Number: "; echo $myrow['PolicyNumber']; echo "<b>First Name: "; echo $myrow['First_Name']; echo "<b>Last Name: "; echo $myrow['Last_Name']; echo "<br><a href=\"edit.php?PolicyNumber=$myrow[PolicyNumber]\">Edit</a> || <a href=\"delete.php?PolicyNumber=$myrow[PolicyNumber]\">Delete</a><br><hr>"; }//end of loop ?> anyone? Link to comment https://forums.phpfreaks.com/topic/137758-solved-database-not-displaying-noob/ Share on other sites More sharing options...
trq Posted December 19, 2008 Share Posted December 19, 2008 You need to put in place some error handling. <?php // load the configuration file. mysql_connect("localhost","root","xxxxxx"); //select which database you want to edit mysql_select_db("database"); if ($result = mysql_query("SELECT * FROM clients ORDER BY ID",$connect)) { if (mysql_num_rows($result)) { while ($myrow = mysql_fetch_assoc($result)) {//begin of loop //now print the results: echo "<b>Policy Number: "; echo $myrow['PolicyNumber']; echo "<b>First Name: "; echo $myrow['First_Name']; echo "<b>Last Name: "; echo $myrow['Last_Name']; echo "<br><a href=\"edit.php?PolicyNumber={$myrow['PolicyNumber']}\">Edit</a> || <a href=\"delete.php?PolicyNumber={$myrow['PolicyNumber']}\">Delete</a><br><hr>"; }//end of loop } else { echo "No results found"; } } else { echo mysql_error(); } ?> Link to comment https://forums.phpfreaks.com/topic/137758-solved-database-not-displaying-noob/#findComment-720027 Share on other sites More sharing options...
savagenoob Posted December 20, 2008 Author Share Posted December 20, 2008 Im getting this error in my Apache log... [Fri Dec 19 19:12:54 2008] [error] [client 127.0.0.1] PHP Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:.....\\clientshow.php on line 15 Link to comment https://forums.phpfreaks.com/topic/137758-solved-database-not-displaying-noob/#findComment-720090 Share on other sites More sharing options...
redarrow Posted December 20, 2008 Share Posted December 20, 2008 $connect <<< what this for.......... Link to comment https://forums.phpfreaks.com/topic/137758-solved-database-not-displaying-noob/#findComment-720091 Share on other sites More sharing options...
savagenoob Posted December 20, 2008 Author Share Posted December 20, 2008 Def a noob, just took out the $connect and it worked. Link to comment https://forums.phpfreaks.com/topic/137758-solved-database-not-displaying-noob/#findComment-720092 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.