|
Posted by Erwin Moller on 10/23/06 09:29
davids58@gmail.com wrote:
> 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?
Did you give readrights to the file for IUSR_<machinename> ?
If that does not help, you might have hitted incompatible versions of PHP
with mySQL, eg a very old MySQL or PHP version.
Read more about it here:
http://nl2.php.net/manual/en/ref.mysqli.php
Regards,
Erwin Moller
>
> TIA,
> David
[Back to original message]
|