mysqli_query and mysqli_fetch_array
| From: | AESB | Date: | Fri, 09 Jan 2009 00:27:06 +0000 |
| Subject: | mysqli_query and mysqli_fetch_array | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-285789@lists.php.net to get a copy of this message | ||
Hope you are all happy and doing well!
I've chosen a piece of chunk of code from a movie browser script known as mysqli_query and mysqli-fetch-array for testing. It's possble a reason preventing it's execution. See any bugs in the following
I'm using APACHE 2.2, PHP 5.2.6 and MySQL 5.1
<?php
// ***** browse_movies.php *****
// Connect to MySQL and select the database:
$dbc = mysqli_connect('localhost', 'xxxx', 'xxxxxxxx','movies') or die ('Could not connect to MySQL: ' . mysqli_connect_error());
// Define the query:
$q = "SELECT first_name, last_name FROM directors";
// Run the query:
$r = mysqli_query($dbc, $q)or die("Error: ".mysqli_error($dbc));
// Display all of the records:
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
echo "{$row['first_name']} <i>{$row['last_name']}</i><br />\n";
}
// Clean up:
mysqli_free_result ($r);
mysqli_close($dbc);
?>