I’m in the middle of E10-4 from 'Learning PHP, MySQL & JavaScript' by Robin Nixon. I have enjoyed the book until two days ago when I got to exercise 10-4 where I was asked to run the following php program:
<?php
require_once 'login.php';
$conn = new mysqli($hn, $un, $pw, $db);
if ($conn->connect_error) die($conn->connect_error);
$query = "SELECT * FROM classics";
$result = $conn->query($query);
if (!$result) die($conn->error);
$rows = $result->num_rows;
for ($j = 0 ; $j < $rows ; ++$j)
{
$result->data_seek($j);
echo 'Author: ' . $result->fetch_assoc()['author'] . '<br>';
$result->data_seek($j);
echo 'Title: ' . $result->fetch_assoc()['title'] . '<br>';
$result->data_seek($j);
echo 'Category: ' . $result->fetch_assoc()['category'] . '<br>';
$result->data_seek($j);
echo 'Year: ' . $result->fetch_assoc()['year'] . '<br>';
$result->data_seek($j);
echo 'ISBN: ' . $result->fetch_assoc()['isbn'] . '<br><br>';
}
$result->close();
$conn->close();
?>
I get the two following error messages:
- Fatal error: Class ‘mysqli’ not found in C:\xampp\htdocs\code\query.php
- PHP Fatal error: Class ‘mysqli’ not found in C:\xampp\htdocs\code\query.php
I’m running the following systems:
- Windows 7 Home Premium
- PHP 5.6.8
- XAMPP Control Panel v3.2.1
- Apache 2.4.12
- Database client version: libmysql - mysqlnd 5.0.11-dev -
- PHP extension: mysqli
I have searched stackoverflow and found a few posts about similar problems but could not pull any information out to solve the problem. I’m new to programming but the responses where over my head. I really have enjoyed this book but this Fatal error is keeping me from doing some great stuff with php and I'm not sure what I can do if I don't get past this issue. I'm sure it is simple to fix. Thanks for your help.