I can't seem to figure out the problem with my database or the connection to it. I get this error when I try to run it.
Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/swiftappandmysql/db/MySQLDAO.php on line 54
AND
Fatal error: Uncaught exception 'Exception' in /Applications/XAMPP/xamppfiles/htdocs/swiftappandmysql/db/MySQLDAO.php:53 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/swiftappandmysql/scripts/registerUser.php(41): MySQLDAO->registerUser('email', 'aske', 'meyer', '1bf528e7f15d11c...', 'KO\x8E\xD0\xCE/\xBD\xACK\xD1d\x18\x9A\x07\xE1...') #1 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/swiftappandmysql/db/MySQLDAO.php on line 53
Connection file:
<?php class Conn { public static $dbhost = "localhost";
public static $dbuser = "root";
public static $dbpass = "";
public static $dbname = "app";} ?>
MySQL file:
public function registerUser($email, $first_name, $last_name, $password, $salt)
{
$sql = "insert into users set email=?, first_name=?, last_name=?, user_password=?, salt=?";
$statement = $this->conn->prepare($sql);
if (!$statement)
throw new Exception($statement->error);
$statement->bind_param("sssss", $email, $first_name, $last_name, $password, $salt);
$returnValue = $statement->execute();
return $returnValue;
}
This is line 54. if (!$statement) throw new Exception($statement->error);