|
Posted by davids58 on 10/23/06 03:18
trying to figure out how to use a mysql database with PHP. I ran the
following code:
<?php
// defines database connection data
define('DB_HOST', 'localhost');
define('DB_USER', 'ajaxuser');
define('DB_PASSWORD', 'practical');
define('DB_DATABASE', 'ajax');
// connect to the database
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
// the SQL query to execute
$query = 'SELECT user_id, user_name FROM users';
//execute the query
$result = $mysqli->query($query);
// loop through the results
while ($row = $result->fetch_array(MYSQLI_ASSOC))
{
// extract user id and name
$user_id = $row['user_id'];
$user_name = $row['user_name'];
// do somthing with the data (here we output it)
echo 'Name of user #' . $user_id . ' is ' . $user_name . '<br/>';
}
// close the input stream
$result->close();
// close the database connection
$mysqli->close();
?>
I get the following message suggesting that it can't find the
mysqli.dll file:
"Fatal error: Class 'mysqli' not found in
C:\Apache\htdocs\ajax\foundations\mysql\index.php on line 13"
I have the following in php.ini:
extension=php_mysqli.dll
I have php_mysqli.dll in php\ext\. I assume that this is where the
class would be implemented. Is that correct?
Any thoughts what the issue might be?
TIA,
David
Navigation:
[Reply to this message]
|