coolman88 Posted May 11, 2007 Share Posted May 11, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/50884-solved-help/ Share on other sites More sharing options...
StormTheGates Posted May 11, 2007 Share Posted May 11, 2007 // 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); Quote Link to comment https://forums.phpfreaks.com/topic/50884-solved-help/#findComment-250271 Share on other sites More sharing options...
coolman88 Posted May 11, 2007 Author Share Posted May 11, 2007 or die(mysql_error($link)) done the trick, thanks alot mate!!!! Quote Link to comment https://forums.phpfreaks.com/topic/50884-solved-help/#findComment-250280 Share on other sites More sharing options...
StormTheGates Posted May 11, 2007 Share Posted May 11, 2007 My pleasure Quote Link to comment https://forums.phpfreaks.com/topic/50884-solved-help/#findComment-250281 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.