It seems that the correct statement does not know the problem and the result is not obtained.

Source: Internet
Author: User
It seems that the correct statement does not know that there is a problem and the result is not obtained... PHPcode $ flagmysql_query (& quot; insertintotb_leaveword (userid, createtime, title, content) values ($ userid, $ createtime, $ title, $ content) & quot ;, $ co feels that the correct statement does not know that there is a problem and the result is not obtained... Help
PHP code
  $flag=mysql_query("insert into tb_leaveword(userid,createtime,title,content) values('$userid','$createtime','$title','$content')",$conn);echo "$flag";

If you do not know why during debugging, echo cannot return the value. The mysql database connection is normal, and each variable can be output using echo. The data is not written to the database. what is the problem?


------ Solution --------------------
PHP code
$ SQL = "insert into tb_leaveword (userid, createtime, title, content) values ('$ userid',' $ createtime', '$ title',' $ content ')"; echo "SQL --> $ SQL
"; $ Flag = mysql_query ($ SQL, $ conn); $ num = mysql_affected_rows (); // echo" num --> $ num
"; If ($ num> 0) {echo" execution successful "; while ($ rows = mysql_fetch_array ($ flag )){......}} Else {echo "execution failed ";}
------ Solution --------------------
Mysql_query ("insert into tb_leaveword (userid, createtime, title, content) values ('$ userid',' $ createtime', '$ title',' $ content ')", $ conn) or die (mysql_error ());

Echo "$ flag"; if nothing happens, your SQL statement is faulty.

Mysql_query only returns the logical value when executing a non-select command. False
Var_dump ($ flag );
------ Solution --------------------
Syntax troubleshooting, but other causes cannot be ruled out. you need to post mysql_error () to know

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.