green917 Posted November 3, 2010 Share Posted November 3, 2010 Hello all, I'm writing a page with a simple database with a table called recipes in it with a series of recipes (go figure). I want to display a list of the recipe titles in ascending alphabetical order with each title linked to another page that displays all of the information about the recipe. I can't seem to get anything to display though (not even the titles) but I'm not getting any errors returned either. It seems as if there is nothing in the table to display (even though there are 40 records there). Any help would be greatly appreciated. Here is the code I have so far: <?php $dbhost = 'localhost'; $dbuser = '*****'; $dbpass = '*****'; $dbname = '*******'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to database'); mysql_select_db($dbname) or die('Error selecting the database'); // select data from db to use $result = mysql_query("SELECT * FROM recipes ORDER BY title ASC LIMIT 0,50") or die('mysql_error()'.'Error: ' .mysql_errno() ); //display the data while($row = mysql_fetch_array($result)); { echo"<b><center>Healthy Lifestyle Gourmet Recipes</center></b><br /><br />"; echo "<span class=\"recipelink\"><a href=\"reciperesults.php?id=".$row['id']."\" target=\"_blank\">".$row['title']."</a></span><br/>\n"; } mysql_close(); ?> I starred out the connection variables but, they are all correct in my code (I'm not getting the "or die" errors) Quote Link to comment https://forums.phpfreaks.com/topic/217712-help-cant-get-the-data-links-to-display-but-no-errors-being-returned/ Share on other sites More sharing options...
Pikachu2000 Posted November 3, 2010 Share Posted November 3, 2010 or die('mysql_error()'.'Error: ' .mysql_errno() ); //<--- Remove the quotes around mysql_error() Quote Link to comment https://forums.phpfreaks.com/topic/217712-help-cant-get-the-data-links-to-display-but-no-errors-being-returned/#findComment-1130108 Share on other sites More sharing options...
DavidAM Posted November 3, 2010 Share Posted November 3, 2010 Hey, you found the semi-colon I lost last night. It's sitting there on your while statement. Its basically creating an empty statement, so the while runs, doing nothing until it has processed all of the rows while($row = mysql_fetch_array($result)); { // ----------------------------------^ Take this semi-colon out The echo's should still be executing after that, so you should get one recipe listed. View the source of the page and see if there is anything there. You might also turn on error reporting at the beginning of your script: error_reporting(E_ALL); ini_set('display_errors', 1); Quote Link to comment https://forums.phpfreaks.com/topic/217712-help-cant-get-the-data-links-to-display-but-no-errors-being-returned/#findComment-1130112 Share on other sites More sharing options...
green917 Posted November 3, 2010 Author Share Posted November 3, 2010 Thank you David AM! That solved the problem. Can't believe I didn't see that extra semi-colon...been looking at it for over an hour. Thanks again! Green917 Quote Link to comment https://forums.phpfreaks.com/topic/217712-help-cant-get-the-data-links-to-display-but-no-errors-being-returned/#findComment-1130116 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.