gpt4 book ai didi

php - MySQL 查询 500 内部服务器错误

转载 作者:行者123 更新时间:2023-11-29 00:12:15 33 4
gpt4 key购买 nike

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

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

变量 $_POST['status']$currentDate$_POST['id'] 的值为我已经在不使用数据库类的情况下进行了测试,而是使用了 mysqli_connect 语句。

有什么帮助吗?

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

}

最佳答案

$stmt -> bind_param("isi", $_POST['status'], $currentDate, $_POST['id']); 空格应该会产生像 解析错误:语法错误,意外的 '->' (T_OBJECT_OPERATOR)?

关于php - MySQL 查询 500 内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24492373/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com