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_PASS WORD', 'practical');
define('DB_DATA BASE', '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(MY SQLI_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\htdoc s\ajax\foundati ons\mysql\index .php on line 13"
I have the following in php.ini:
extension=php_m ysqli.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
following code:
<?php
// defines database connection data
define('DB_HOST ', 'localhost');
define('DB_USER ', 'ajaxuser');
define('DB_PASS WORD', 'practical');
define('DB_DATA BASE', '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(MY SQLI_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\htdoc s\ajax\foundati ons\mysql\index .php on line 13"
I have the following in php.ini:
extension=php_m ysqli.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
Comment