The insert command is always unable to insert into the mysql database.

Source: Internet
Author: User
This is the connect. php file. this is the add. php file. mysql_query ($ SQL); if (mysql_query ($ SQL) {echo mysqlphp database

This is the connect. php file.

@ Mysql_connect ("localhost: 3306", "root", "123456") or die ("SQL connection failed"); @ mysql_select_db ("yhy ") or die ("yhy connection failed"); // mysql_query ("set names 'gb2312 '"); mysql_set_charset ("gbk ");

?>

This is the add. php file.
Include ("connect. php"); // introduce the database connection module
If (! Empty ($ _ POST ['sub'])
{

$ Title = $ _ POST ['title'];
$ Con = $ _ POST ['con '];
$ SQL = "insertYhy100(Id,Title,Dates,Contents) Values (null, '$ title', now (),' $ con ')"."
";
Mysql_query ($ SQL );
If (mysql_query ($ SQL ))
{
Echo "successful insertion ";
}
Else
Echo "insertion failed ";

}

?>

Title
Content

When I was a beginner in PHP, there was no problem connecting to the database, but every time I clicked "post", I was prompted that the insertion failed and I was always unable to insert the data into the database. such a small routine would have killed me, could you please advise me ....

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.