The feeling is the correct statement I do not know there is a problem, there is no result.

Source: Internet
Author: User
The feeling is the correct statement do not know there is a problem, not get the results ... Help
PHP Code
  
   $flag =mysql_query ("INSERT into Tb_leaveword (userid,createtime,title,content) VALUES (' $userid ', ' $createtime ', ' $ Title ', ' $content ') ", $conn); echo" $flag ";

During debugging, I don't know why, Echo can't get the return value. The MySQL database connection is normal, and each subsequent variable can be hit with Echo. The data is not written into 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 (); The number of rows affected by the execution of SQL echo "num-->> $num
"; if ($num > 0) {echo "executed successfully"; 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"; nothing means you have a problem with your SQL statement

Mysql_query returns only logical values when executing a non-select instruction. False with Echo can only be no content
to Var_dump ($flag);
------Solution--------------------
Syntax problem excluded, but other reasons can not be excluded, 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.