Home > Backend Development > PHP Tutorial > 感觉是正确的语句不知那里出了有关问题,得不到结果。

感觉是正确的语句不知那里出了有关问题,得不到结果。

WBOY
Release: 2016-06-13 10:14:41
Original
837 people have browsed it

感觉是正确的语句不知那里出了问题,得不到结果。。。求助

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$flag=mysql_query("insert into tb_leaveword(userid,createtime,title,content) values('$userid','$createtime','$title','$content')",$conn);echo "$flag";
Copy after login

调试过程中,不知道为什么,echo打不出来返回值。mysql数据库连接是正常的,后面每个变量也都可以用echo打出来。数据也没写到数据库里面,到底出了什么问题呢?


------解决方案--------------------
PHP code
$sql="insert into tb_leaveword(userid,createtime,title,content) values('$userid','$createtime','$title','$content')";echo "sql-->>$sql<br>";$flag=mysql_query($sql,$conn);$num = mysql_affected_rows();  //执行sql所影响的行数echo "num-->>$num<br>";if($num > 0){  echo "执行成功";  while($rows = mysql_fetch_array($flag)){……}}else{  echo "执行失败";}<br><font color="#e78608">------解决方案--------------------</font><br>mysql_query("insert into tb_leaveword(userid,createtime,title,content) values('$userid','$createtime','$title','$content')",$conn) or die(mysql_error());<br><br>echo "$flag"; 没有东西就表示你的 SQL 语句有问题了<br><br>mysql_query 在执行非 select 指令时,只返回逻辑值。false 用 echo 只能是没有内容<br>要 var_dump($flag); 才行<br><font color="#e78608">------解决方案--------------------</font><br>语法问题排除,但其它原因就没法给你排除,你需要贴出mysql_error()才能知道<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
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