SQL PHP语句中的解析错误

时间:2014-07-15 13:19:53

标签: php mysql sql

以下语句在执行时会出错:

$stmt=$db->prepare ("INSERT INTO cabs (NAME,IDNO,HOSTEL,MODE,DATE,TIME,TFNO,CONTACT)
VALUES
(:name,:idno,:hostel,:mode,:date,:time,:tfno,:contact)");

$stmt->bindParam (':name',$_POST[name]);

错误陈述:

Fatal error: Call to a member function bindParam() on a non-object in C:\wamp\www\overflow\rew1.php on line 27

1 个答案:

答案 0 :(得分:1)

添加'

$stmt=$db->prepare ("INSERT INTO cabs (NAME,IDNO,HOSTEL,MODE,DATE,TIME,TFNO,CONTACT)
VALUES
(:name,:idno,:hostel,:mode,:date,:time,:tfno,:contact)");

$stmt->bindParam (':name',$_POST[name], PDO::PARAM_STR);

检查http://php.net/manual/de/pdostatement.bindparam.php

上的示例