Reputation: 1143
Why am I getting an error in my file processApplication.php?
I am just trying to use my database class to get a MySQL connection so I can prepare my SQL statement before I execute it.
The variables, $_POST['status']
, $currentDate
, and $_POST['id']
do have values as I've tested this without using the database class but instead using a mysqli_connect
statement.
Any help please?
processApplication.php
<?PHP
include_once '../lib/variables.php';
include_once '../lib/database.php';
//make sure user is valid
if(check_ses_vars() != '') {
date_default_timezone_set('America/New_York');
$currentDate = date('m/d/Y');
$query = "UPDATE Application SET hasBeenPushed = ?, pushedDate = ? WHERE applicationId = ?";
$db = Database::get();
$stmt = $db->prepare($query);
$stmt -> bind_param("isi", $_POST['status'], $currentDate, $_POST['id']);
$results = $stmt->execute();
}
?>
And Database.php:
include_once "variables.php";
class Database {
var $database_name;
var $database_user;
var $database_pass;
var $database_host;
var $database_link;
private static $instance;
function Database($user=null, $pass=null, $host=null, $name=null)
{
$this->database_user = isset($user)?$user:$GLOBALS["db_user"];
$this->database_pass = isset($pass)?$pass:$GLOBALS["db_pass"];
$this->database_host = isset($host)?$host:$GLOBALS["db_host"];
$this->database_name = isset($name)?$name:$GLOBALS["db_name"];
}
public static function get()
{
if (!isset(self::$instance)) {
$c = __CLASS__;
self::$instance = new $c;
self::$instance->connect();
}
return self::$instance;
}
function connect()
{
$this->database_link = new mysqli(
$this->database_host,
$this->database_user,
$this->database_pass,
$this->database_name
);
/* check connection */
if (mysqli_connect_errno($this->database_link)) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
}
}
Upvotes: 1
Views: 3337
Reputation: 96
$stmt -> bind_param("isi", $_POST['status'], $currentDate, $_POST['id']);
the spaces should create a parse error like Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)
?
Upvotes: 1