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