欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

我这个代码为什么提示这个错误呢?

程序员文章站 2024-02-12 15:33:40
...
提示这个错误 哪里不对了?
( ! ) Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ')' in D:\wamp\www\prepare.php on line 4
代码如下
$pdo=new PDO("mysql:host=localhost;dbname=t1","root","");
$stnt=$pdo->prepare("insert into blog2 (type,name,num,content)values(:type,:name,:num,:content) ");
$stnt->execute(array("type"->"5","name"->"5","num"->"5","content"->"5"));
?>


回复讨论(解决方案)

$stnt->execute(array(":type"=>"5",":name"=>"5",":num"=>"5",":content"=>"5"));

$stnt->execute(array(":type"=>"5",":name"=>"5",":num"=>"5",":content"=>"5"));

哦 谢谢 冒号还得加上啊