PHP page cannot be written into the database! It hurts for two days!
Source: Internet
Author: User
The PHP page cannot be written into the database !!! It hurts for two days !! The code of the page of the church. phpPHP is as follows: & lt ;? Php $ conn = mysql_connect (& quot; localhost & quot;, & quot; root & quot;, & quot; 5125241 & quot ;) ordie (the & PHP page cannot be written into the database !!! It hurts for two days !!
Church. 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 ("The database does not exist ");
Mysql_query ("insert into news set title = 'This is the first title '");
?>
You can write database data in myadmin !! But nothing can be written on the php page! The php page does not display any errors! But there is no data in the database ~!!! Hope you can correct me!
I have read a lot on the Internet, but nothing has been done! Headaches ,,,,,,,,,,,,
Now, my wamp is semi-yellow and semi-White. then, if a port is occupied, cannot be written into the database ?? But I changed my port number 3306 to 3333.
Wamp is completely white, but it cannot be inserted into the database !!!
------ Solution --------------------
$ Conn = mysql_connect ("localhost: 3333", "root", "5125241") or die ("database link error ");
Mysql_select_db ("test", $ conn) or die ("The database does not exist ");
Mysql_query ("insert into news set title = 'this is the first title'") or die (mysql_error ());
I don't know what the situation is that my wamp is half-yellow and half-white?
Which program occupies Port 3306?
------ Solution --------------------
The root user's password is incorrect and access is denied.
------ Solution --------------------
Windows is not clear to me. you can stop the wamp server and check whether the process still exists.
If it exists, it is crowding out mysql that comes with wamp
------ Solution --------------------
Field 'content' doesn' t have a default value
No default value for the field 'content'
You can set a default value for it or remove the not null attribute.
------ Solution --------------------
This indicates that the database can be connected, but the SQL statement has a problem:
In the news table, you must set a field as not null (the value cannot be blank). you must set a default value for it or set a value for each insert. It seems that the content field stores the News body. a news item cannot have only a title.
Insert into news ('title', 'Content') VALUES ('This is the title', 'This is the body ')
------ Solution --------------------
It is not because of a php insertion problem, but because your database is designed improperly and cannot be inserted ..
Paste your table structure
Discussion
Use the php page to insert simple mysql database code!
------ Solution --------------------
Discussion
Paste your table structure
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