PHP script error
Im getting this error:
Fatal error: Call to a member function query() on a non-object in C:\EasyPHP-5.3.6.0\www\Database Manager\install\registration.php on line 18
Heres my code:
<?php
include("../sql_information.php");
class infos {
private $sql_initialize;
function login_details() {
$sql_initialize = new MySQLDatabase();
$sql_initialize;
user_name='$register_user_name'";
$queryresult = $this->sql_initialize->query($sql);
if ($sql_initialize->fetchArray($queryresult)) {
$errors[] = "Username already taken";
}
if ($register_password !== $confirm_password) {
$errors[] = "Passwords mismatch";
}
if (!$errors) {
//$register_password = mysql_real_escape_string($register_password);
$sql = "INSERT INTO `data_manager`.`user_accounts` (`id`, `user_name`, `password`) VALUES (NULL, '$register_user_name', '$register_password')";
mysql_query($sql);
print "registered !";
//header("Location: complete.php");
开发者_JS百科 exit;
} else {
foreach ($errors as $err) echo $err;
}
}
}
?>
In the first line of login_details
, you're setting the local variable $sql_initialize
. You need to be setting $this->sql_initialize
instead.
$sql_initialize = new MySQLDatabase();
...
$queryresult = $this->sql_initialize->query($sql);
You're probably trying to create the object on $this->sql_initialize
there, not $sql_initialize
.
most likely is that MySQLDatabase did not return an object due to an error, probably in the MySQLDatabase class!!
精彩评论