我正在从 mysql_connect 切换到 pdo 并且无法继续。这是我的代码:
//get the row sk
$sk = strtok($string, "_");
//get the column name (the rest of the $string)
$column_name = substr($string, strpos($string, "_") + 1);
//get the value
$value = $_SESSION['save_arr'][$string];
echo "{$column_name} {$value} {$sk}</br>";
$sql = "update tbl_brand set ?=? where brand_sk=?";
$q = $pdo_conn->prepare($sql);
$q->execute(array($column_name, $value, $sk));
如果我硬编码一些值,那么它工作正常
$sql = "update tbl_brand set name_long='name' where brand_sk='1'";
我确定这只是一个语法问题,但我看不到它。我正在处理这个例子http://www.phpeveryday.com/articles/PDO-Error-Handling-P552.html
回声的结果是这样的:
name_long National Autjho Glass 2