Jump to content

HELP! Can't get the data links to display but, no errors being returned


green917

Recommended Posts

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)

Link to comment
Share on other sites

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);

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.