Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php bindParam错误_Php_Pdo - Fatal编程技术网

Php bindParam错误

Php bindParam错误,php,pdo,Php,Pdo,我在我的MAMP服务器上收到一个错误,它正常工作,但在我的live服务器上有一个错误: 分析错误:语法错误,意外“[”,应为“')” 如何解决这个问题?出了什么问题或为什么 我的代码: try { $sql = "INSERT INTO collection (name, numberO, city) VALUES (:name, :numberO, :city)"; $statement = $db->prepare($sql); $sth = $statemen

我在我的MAMP服务器上收到一个错误,它正常工作,但在我的live服务器上有一个错误:

分析错误:语法错误,意外“[”,应为“')”

如何解决这个问题?出了什么问题或为什么

我的代码:

try {
    $sql = "INSERT INTO collection (name, numberO, city) VALUES (:name, :numberO, :city)";
    $statement = $db->prepare($sql);
    $sth = $statement->execute( ['name' => $name, 'numberO' => $number, 'city' => $city] );
} catch(PDOExepction $e) {
    echo "SORRY";
    exit;
}

检查服务器的php版本

您需要PHP5.4+来使用速记数组

asp per:

从PHP5.4开始,您还可以使用短数组语法,它将数组()替换为[]

1) 更新php版本或

2) 更改快捷数组语法检查服务器的php版本

您需要PHP5.4+来使用速记数组

asp per:

从PHP5.4开始,您还可以使用短数组语法,它将数组()替换为[]

1) 更新php版本或
2) 更改快捷数组语法

试试这个

$sth = $statement->execute(array(
    ':name' => $name, 
    ':numberO' => $number, 
    ':city' => $city
));
从PHP5.4开始,您还可以使用短数组语法,它将数组()替换为[]。 试试这个

$sth = $statement->execute(array(
    ':name' => $name, 
    ':numberO' => $number, 
    ':city' => $city
));
从PHP5.4开始,您还可以使用短数组语法,它将数组()替换为[]。

您使用的旧PHP版本不支持
[]
数组快捷方式符号。请改用
->execute(array(..)
。您使用的旧PHP版本不支持
[]
数组快捷方式符号。请使用
->execute(array(..)
。服务器版本为:5.3.28服务器版本为:5.3.28