本文介绍了pdo执行给出的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
昨天我的主题是"pdo插入和更新.现在这里是
Yesterday i had this topic with "pdo inserting and updating. Now here is the following
Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in on line 148
这是我的代码.
$sth = $db->prepare(
'INSERT INTO track (`rsname`, `overallranknow`, `overalllevelnow`, `overallxpnow` )' .
'VALUES (:name, :Overalln, :Overall1, :Overall2) '.
'ON DUPLICATE KEY UPDATE ' .
"rsname = :name" .
"overallranknow = :Overalln" .
"overalllevelnow = :Overall1" .
"overallxpnow = :Overall2"
);
$sth->bindValue(':name', $name, PDO::PARAM_STR);
$sth->bindValue(':Overalln', $Overalln, PDO::PARAM_INT);
$sth->bindValue(':Overall1', $Overall[1], PDO::PARAM_INT);
$sth->bindValue(':Overall2', $Overall[2], PDO::PARAM_INT);
$sth->execute();
该错误表明我的执行行是错误的1.我已经尝试过使用数组,但是我仍然得到了它.我希望也许知道我的意思.
The error says my execute line is the wrong 1. I have tried it with a array and i still got it then. I hope maybe knows what i mean.
〜Kev(英语不好=抱歉)
~Kev (bad english = sorry)
推荐答案
INSERT INTO track (rsname, overallranknow, overalllevelnow, overallxpnow)
VALUES (:name, :Overalln, :Overall1, :Overall2)
ON DUPLICATE KEY UPDATE
rsname = values(rsname),
overallranknow = values(overallranknow),
overalllevelnow = values(overalllevelnow),
overallxpnow = values(overallxpnow)
必须如此.
这篇关于pdo执行给出的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!