PHP is unable to insert data into MySQL
Source:
$db =new mysqli ("localhost", "root", "5832528");
$db->select_db ("books");
$query 1 = "INSERT into books values (' 123-457 ', ' zhp ', ' C + + ', 56)";
if (Mysqli_connect_errno ()) {
Echo ' connection error ';
Exit
}
$result = $db->query ($query 1);
if ($result)
echo $db->affected_rows ' book inserted into database ';
Else
echo "Error";
$db->close ();
In the phpMyAdmin to execute the query statement is not a problem, the database can also be connected up, execute queries and so on. Who can't get the data into MySQL?
------Solution--------------------
Will this sentence, insert into books values (' 123-457 ', ' zhp ', ' C + + ', 56), directly into the database, to see if there is an error? It is possible that the sentence itself is wrong, so that you do not insert PHP into the data ...
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