What's wrong with my code? mysql_query does not work and no error is reported. & lt ;? Include (& quot; in. php & quot;); if (empty ($ _ POST ['ybt ']) {mysql_close (); echo & quot; & lt; script & gt; alert ('What's wrong when I illegally submit this code? mysql_query does not work and no error is reported.
Include ("in. php ");
If (empty ($ _ POST ['ybt '])
{
Mysql_close ();
Echo "script alert ('illegal submission! Please submit again! '); History. back (); script ";
Exit;
}
$ YLX = 'Exhibition information ';
$ Exe = "insert into yzx (YLX, YNR, YBT, YDT) values ('$ ylx ','". phpasp2 ($ _ POST ["YNR"]). "','". htmlencode2 ($ _ POST ['ybt ']). "','". time (). "')";
$ Result = mysql_query ($ exe );
Mysql_close ();
Echo "script" alert ('added successfully! '); Location. href = 'newslist. php'; script ";
Exit;
?>
------ Solution --------------------
$ Result = mysql_query ($ exe) or die (mysql_error ());
If any error occurs, post it.
------ Solution --------------------
If you do not design a table, you want to automatically add value, but the table does not set YID to auto-increment.
Discussion
Field 'Yid' doesn' t have a default value. However, YID is automatically added to the value I want.
------ Solution --------------------
PHP code
// Check whether the SQL statement is correct echo "SQL -- >>{$ exe}
"; If (mysql_affected_rows ()> 0) {// if the execution is successful echo" script alert ('added successfully! '); Location. href = 'newslist. php'; script ";} else {mysql_close (); echo" script "alert (' addition failed! '); Return; script "; exit;} mysql_close ();