Home > Backend Development > PHP Tutorial > 我这个代码为什么提示这个错误呢?

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

WBOY
Release: 2016-06-23 13:19:40
Original
921 people have browsed it

提示这个错误  哪里不对了?
( ! ) 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"));
Copy after login
Copy after login

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


 哦 谢谢  冒号还得加上啊 
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template