Home >Backend Development >PHP Tutorial >这个PDO插入数据库页面后面该怎么写呢?

这个PDO插入数据库页面后面该怎么写呢?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-20 12:41:38890browse

写了一点  试了一下 提示这样的错误  
( ! ) Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in D:\wamp\www\blog.php on line 4 

提交页面










    
    





插入页面
 $pdo=new PDO("mysql:host=localhost;dbname=t1","root","");
 $pdo->exec("INSERT INTO blog(content)
 VALUES('$_POST['content']'))


?>


回复讨论(解决方案)

 $pdo->exec("INSERT INTO blog(content)  VALUES('$_POST['content']'))
这行有问题,试试这样:
 $pdo->exec("INSERT INTO blog(content)  VALUES(".$_POST['content'].")");

$pdo->exec("INSERT INTO blog (content)  VALUES ('$_POST[content]')“)

 $pdo->exec("INSERT INTO blog(content)  VALUES('$_POST['content']'))
这行有问题,试试这样:
 $pdo->exec("INSERT INTO blog(content)  VALUES(".$_POST['content'].")");


换成你的代码  现在不提示错误了  但是提交后我查看数据里面并没有插入内容  怎么回事?
Statement:
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