Jump to content

Recommended Posts

Hi guys im still quite new to php, I am currently working on a segment of code that keeps returning the same error no matter what I try

This is the error

 

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\Program Files\xampp\htdocs\list.php on line 56

 

here is the code in question

 

 

while ($row = mysqli_fetch_array($result)) 
{

 

 

And now here is all the code

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Dalmation Association - Dog List</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<p><h1>Dalmation Association - Dog List</h1></p>


<table border="0">
<tr>
	<th>ID Number</th>
	<th>Name</th>
	<th>Sex</th>
	<th>Date Of Birth</th>
	<th>Price</th>
	<th>Breeder</th>
</tr>
<?
// Opens the connection to database to access the data
$link = mysqli_connect('localhost', 'user', 'password, 'fromthedatabase');







// A query that retrieves the data from both tables with in the database

$select = "SELECT
		dogs.dog_id,
		dogs.dog_name,
		dogs.dog_sex,
		dogs.dog_price,
		dogs.dog_birth,
		breeders.breeder_first_name,
		breeders.breeder_last_name
		FROM dogs, breeders
		WHERE dogs.breeder_id = breeders.breeder_id";



// Store the result
$result = mysqli_query($link, $select);




// Close the connection
mysqli_close($link);





// Assign each record in the result to an array
while ($row = mysqli_fetch_array($result)) 
{




// Assign the variables
$dog_id = $row['id_no'];
$dog_name = $row['name'];
$dog_sex = $row['sex'];
$dog_birth = $row['birth'];
$dog_price = $row['price'];
$breeder_first_name = $row['breeder_firstname'];
$breeder_last_name = $row['breeder_lastname'];

// Display the results on seperate lines
echo <<<END
<tr>
	<td>$id_no</td>
	<td>$name</td>
	<td>$sex</td>
	<td>$birth</td>
	<td>$$price</td>
	<td>$breeder_firstname $breeder_lastname</td>
</tr>
END;
}

// Closes the table
echo"</table>";

?>
</body>
</html>

 

 

so any help you could give me would be very appreciated!!

 

Thanks

tom

Link to comment
https://forums.phpfreaks.com/topic/50884-solved-help/
Share on other sites

// Opens the connection to database to access the data

$link = mysqli_connect('localhost', 'user', 'password, 'fromthedatabase');

 

That is throwing an error. If you are connecting to the db try this:

 

$db = mysql_connect("localhost", "name", "password") or die(mysql_error()); 
mysql_select_db("game", $db);

Link to comment
https://forums.phpfreaks.com/topic/50884-solved-help/#findComment-250271
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.