douzhuozhu9544
2015-09-02 13:38
浏览 75
已采纳

PHP:PDO MySQL错误

I don't really know MySQL but I try.

I have this script in PHP

$sql = $DB->prepare("INSERT INTO `users`(`id`, `firstname`, `lastname`, `email`, `password`) VALUES ($this->firstname, $this->lastname, $this->email, $this->password))");

and when I use

print_r($sql->errorInfo());

It is giving me this error

Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: no parameters were bound in C:\Bitnami\wampstack-5.5.27-0\apache2\htdocs\OOPLoginegister.php on line 115 Array ( [0] => HY093 [1] => [2] => )

If anyone could help me, I would appreciate it very much.

Thank you.

EDIT: I changed it to

$sql = $DB->prepare("INSERT INTO `users`(`firstname`, `lastname`, `email`, `password`) VALUES ($this->firstname, $this->lastname, $this->email, $this->password))");

And now it's giving me

Array ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@gmail.com, ff0b80f26259f9c0178aeed5198bac48))' at line 1 )

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

4条回答 默认 最新

相关推荐 更多相似问题