PHP page does not write into the database related issues! The egg hurts for two days!
Source: Internet
Author: User
PHP page does not write database problems!!! The egg hurts for two days!!
churu.php
The PHP page code is as follows:
$conn =mysql_connect ("localhost", "root", "5125241") or Die ("Database link error");
mysql_select_db ("Test", $conn) or Die ("database does not exist");
mysql_query ("INSERT into news set title= ' This is the first title '");
?>
Database data can be written in MyAdmin!! But in the PHP page is nothing to write in! Implementation is PHP page does not show what error! But there's no data in the database ~!!! Hope the heroes correct me!
On the internet to see a lot of but what changes are not the effect! Headache, 、、、、、、、、、、、、
Now my wamp is half yellow and half white and then ask a little bit of the port is not written into the database ah?? But I changed my port number 3306 to 3333.
Wamp all white, but just can't plug in database data!!!
------Solution--------------------
$conn =mysql_connect ("localhost:3333", "root", "5125241") or Die ("Database link error");
mysql_select_db ("Test", $conn) or Die ("database does not exist");
mysql_query ("INSERT into news set title= ' which is the first title '") Or Die (Mysql_error ());
I do not know what you said my wamp is half yellow and half white what is the situation?
Which program is the 3306 port occupied by?
------Solution--------------------
The root user's password is wrong and access is denied.
------Solution--------------------
Windows I'm not sure that you can stop Wamp server and then see if this process still exists.
If it exists, it's crowding out Wamp's own MySQL.
------Solution--------------------
Field ' content ' doesn ' t has a default value
Field ' content ' has no default value
You set a default value for it, or remove the not NULL property.
------Solution--------------------
This means that you can connect to the database, but there is a problem with the SQL statement:
There is a field in the news table that you set to NOT NULL (the value cannot be empty), you must either give it a default value, or set a value for each insert. It seems that the content field is stored in the news body, a news can not only title
INSERT INTO News (' title ', ' content ') VALUES (' This is the title ', ' This is the body ')
------Solution--------------------
Now is not the PHP insertion problem, but your database design unreasonable cannot insert data.
Put the structure of your table and look at it.
discuss
Simple code for inserting a MySQL database into a PHP page!
------Solution--------------------
discuss
Put the structure of your table and look at it.
------Solution--------------------
Should be a problem with the database
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.