mysql_fetch_array() expects parameter 1 to be resource, boolean

First, I didn’t know exactly where to place this thread. I am a beginner, but it involves MySQL… So sorry if I’m wrong!

Anyway, I’ve used this code for a while on a couple different host, and I’ve never had a problem with it, but on this new host it echos “mysql_fetch_array() expects parameter 1 to be resource, boolean given in /FILELOCATION/ on line 277”
I basically copied this code from a guestbook tutorial a while back, modifying a little. It’s having a problem at the while line.

[php]<?
$host = “localhost”;
$name = “";
$pass = "
”;
$dbname = “*****”;

					// Connect to Database and select the database to use
					$dbi = mysql_connect($host, $name,$pass) or
					die("I cannot connect to the database. Error :" . mysql_error());
					mysql_select_db($dbname,$dbi);
					
					// Fetch and Display the Results from the Database
					$result = mysql_query("select name, email, v_comment from
					guestbook ORDER BY id DESC LIMIT 5",$dbi);
		
					while ($myrow = mysql_fetch_array($result))
					{
					list($name, $email, $comment) = $myrow;
					$name    = htmlspecialchars($name);
					$comment = htmlspecialchars($comment);
					echo "<strong>Name:</strong> $name<br> <strong>Comment:</strong>                     $comment<br><br> ";
					}
					?>[/php]

Did u check ur database to make sure the table names etc. are all correct? I don’t notice any other mistake unless something somewhere else is conflicting with your code

I created the user but forgot to add the user to the database! -facepalm-
Ohhh dear. Hahaha.

Haha… Glad to know it works… :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service