Php cannot insert data into the mysql source code: $ db & nbsp; = new & nbsp; mysqli ("localhost", "root", "5832528 "); $ db-& gt; select_db ("books"); $ query1 & nbsp; = & nb 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...
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.