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