我对此有点困惑,我认为问题是在带空格的字段中插入数据,这是正确的方法吗?
我得到的错误信息是:
数据库错误:SQLSTATE [HY093]:参数号无效:绑定变量数与令牌数不匹配
$consulta = "INSERT INTO $table
(Title, Title_Short, City, `Department / Branch`)
VALUES (:Title, :Title_Short, :City, :`Department / Branch`)";
$result = $db->prepare($consulta);
$result->execute(array(
":Title" => getTitle($url_job),
":Title_Short" => getTitle_Short($url_job),
":City" => getTitle($url_job),
":Department / Branch" => getTitle_Short($url_job),
));
答案 0 :(得分:1)
占位符不允许使用特殊字符。使用:
$consulta = "INSERT INTO $table
(Title, Title_Short, City, `Department / Branch`)
VALUES (:Title, :Title_Short, :City, :DeptBranch)";
$result = $db->prepare($consulta);
$result->execute(array(
":Title" => getTitle($url_job),
":Title_Short" => getTitle_Short($url_job),
":City" => getTitle($url_job),
":DeptBranch" => getTitle_Short($url_job),
));