davt55 Posted February 13, 2011 Share Posted February 13, 2011 I cannot retrieve my records from my table, neither can I display them on my website. I do not even get any errors when I run the script on my site. Any help or tips would be greatly appreciated. My current php script is: // connection to database server $db_selected = mysql_select_db('database1', $dbc); if (!$db_selected) { die ('Can\'t use database1 : ' . mysql_error()); } $query = "SELECT * FROM chesstable ORDER BY chapter, lastname"; $result = mysql_query($query) or die('Could not connect' . mysql_error()); echo mysql_num_rows($result); If (!$result) { $message = 'Invalid query: ' . mysql_error(); $message = 'Whole query: ' . $query; die ($message); } while($row = mysql_fetch_assoc($result)) { echo $row['firstname'] . " " . $row['lastname'] . $row['chapter']; } mysql_free_result($result); mysql_close($dbc); ?> Quote Link to comment Share on other sites More sharing options...
ruddie Posted February 13, 2011 Share Posted February 13, 2011 Well, I normally never use mysql_fetch_assoc, since I always get troubled with it.. I would simply do this: $numOfRows = mysql_num_rows($result); $i = 0; while ( $i < $numOfRows ) { mysql_result($result,$i,"firstname"); mysql_result($result,$i,"lastname"); mysql_result($result,$i,"chapter"); // echo stuff } Although it might seem inefficient, it always worked for me, so that's fine. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 13, 2011 Share Posted February 13, 2011 | | V (errors) Quote Link to comment Share on other sites More sharing options...
ruddie Posted February 13, 2011 Share Posted February 13, 2011 | | V (errors) Is that about my post? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 13, 2011 Share Posted February 13, 2011 | | V (errors) Is that about my post? *sigh* No, it was my response to the Op saying he gets no errors. 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.