MySQL查询500内部服务器错误

时间:2014-06-30 14:23:46

标签: php mysql

为什么我的文件processApplication.php中出现错误?

我只是想使用我的数据库类来获取MySQL连接,这样我就可以在执行之前准备好我的SQL语句。

变量$_POST['status']$currentDate$_POST['id']确实有值,因为我在不使用数据库类的情况下测试了它,而是使用mysqli_connect语句。< / p>

请帮忙吗?

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();

}
?>

和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();
    }
}

}

1 个答案:

答案 0 :(得分:1)

$stmt -> bind_param("isi", $_POST['status'], $currentDate, $_POST['id']);空格应该创建一个解析错误,如Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR)