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...