anyone knows why i get this error:
Call to a member function prepare() on a non-object
for this code-snippet:
public function check_availability($dataID) {
$query = "SELECT dump FROM dumps WHERE dump = '".$dataID."'";
if ($stmt = $mysqli->prepare($query)) {
$stmt->execute();
if($stmt->rowCount() > 0) {
return FALSE;
} else {
return TRUE;
}
$stmt->close();
}
}
especially for this line:
if ($stmt = $mysqli->prepare($query)) {
the variable $mysqli cant be wrong because of:
$mysqli = new mysqli($config['sql_hostname'], $config['sql_username'], $config['sql_password'], $config['sql_database']);
UPDATE:
i am calling this script in browser:
define('SECURE', true);
include "storescripts/connect_to_mysql.php";
require 'AvailabilityChecker.php';
$config = array('DB' => $mysqli,
'Table' => 'dumps',
'Row' => 'dump',
'Output' => true,
'Format' => 'JSON');
$availabilityChecker = new AvailabilityChecker($config);
if($availabilityChecker->check_availability($_POST['dataID'])) {
echo "ok";
} else {
echo "not ok";
}
$mysqli is defined in "connect_to_mysql.php" so?