Php cannot insert data into mysql

Source: Internet
Author: User
Php cannot insert data into mysql source code: $ db & nbsp; new & nbsp; mysqli (localhost, root, 5832528); $ db-& gt; select_db (books ); $ query1 & nbsp; insert & nbsp; into & nbsp; books & nbsp; values (123-45 php cannot insert data into mysql
Source code:
$ Db = new mysqli ("localhost", "root", "5832528 ");
$ Db-> select_db ("books ");
$ Query1 = "insert into books values ('2017-123 ', 'zhp', 'c ++ ', 56 )";
If (mysqli_connect_errno ()){
Echo 'connection error ';
Exit;
}
$ Result = $ db-> query ($ query1 );
If ($ result)
Echo $ db-> affected_rows. 'Book inserted into database ';
Else
Echo "Error ";
$ Db-> close ();

It is okay to run the query statement in phpmyadmin, and the database can also be connected, so there is no problem in executing the query. No one can insert data into mysql.
------ Solution --------------------
Insert into books values ('1970-123 ', 'zhp', 'c ++ ', 56) into the database to see if an error is returned? This sentence may be incorrect, so you cannot insert data into php...

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.