When I do my DB connection like this:
$conn = new MySQLi(RUBYDBUSER, RUBYDBNAME, RUBYDBPASS, RUBYDBDATA);
if($conn->errno) {
throw new Exception($conn->connect_error, $conn->connect_errno);
}
and I want to run a prepared statement like this:
public function getSitename() {
$stmt = $conn->prepare("SELECT value FROM cms_options WHERE title = 'sitename' ");
$db->stmt_init();
$stmt->execute();
$stmt->bind_result($sitename);
if($stmt->num_rows > 0) {
while ($stmt->fetch) {
return $sitename;
}
}
}
I get this error:
Notice: Undefined variable: conn in C:\xampp\htdocs\ruby\app\includes\classes\class.core.php on line 26
The query is in class.core.php
and the connection in global.php
. The Class.core is included like this:
(global.php)
foreach(glob(RUBY_BASE . '/app/includes/classes/class.*.php') as $class){
include_once($class);
}
Any answers? `