I've run into a problem with a script on a new host which throws up "Fatal error: Class sql: Cannot inherit from undefined class mysqli" when trying to use mysqli for a class. I think this may be down to fact safemode is off but as I cannot change this remotely and I'm still a newbie in terms of classes, if anyone could help it'd be much appreciated.
classes script
class Sql extends mysqli {
function __construct($host, $user, $password, $table) {
parent::__construct($host, $user, $password, $table);
}
function getdata($SQL, $force=0) {
static $holdQuery;
static $result;
if ($SQL != $holdQuery) {
$result = $this->query($SQL) or die("Error: ".$this->error);
$holdQuery = $SQL;
}
return $result->fetch_assoc();
}
function countrows($field, $table){
$result = $this->query("SELECT $field FROM $table") or die("Error: ".$this->error);
return $result->num_rows;
}
this is the code within the page
<?php
include('includes/config.inc.php'); // Database Details
include('includes/classes.inc.php'); // Classes
// Connect to DB
$link = new Sql("$dbhost","$dbuser","$dbpass","$dbname");
// Get and display data
$SQL = "SELECT * FROM people LIMIT 10";
while ($row = $link->getdata($SQL)) {
printf("%s<br />", $row["dob"]);
}
// close connection
$link->close();
?>