What's wrong with this code? mysql_query does not work and no error is reported.

Source: Internet
Author: User
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 ();

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.