Data cannot be inserted, but data can be updated.

Source: Internet
Author: User
Data cannot be inserted, but data can be updated on my page. there is no problem with data insertion or update locally. After uploading the server, this page can update data, but cannot insert data. Can you give me a solution? Thank you.


Reply to discussion (solution)

Check whether the insert permission exists.

Are you talking about database settings in the space? After uploading a space on the My EDIT page, it can only be updated but cannot be inserted. after uploading a space on the login page, it can also be inserted.

My edit page code is

Session_start ();
Include ("IncDB. php ");
// Process submitted changes @ allprojects @ todo multi-query
@ $ Uid = $ _ SESSION ['id'];
If (! Empty ($ _ POST ['submit ']) {
$ Bid = $ _ POST ['bid'];
$ Bidt = addslashes ($ _ POST ['title']);
$ Bidl = addslashes ($ _ POST ['link']);

$ Result1 = mysql_query ("SELECT * FROM userlinks where id = '$ bid' and userid ='". $ _ SESSION ['id']. "'", $ link );
$ Row1 = mysql_fetch_row ($ result1 );
If ($ row1 = null)
{
$ SQL = "INSERT INTO 'userlink' ('id', 'title', 'link', 'userid', 'datetime') VALUES ('$ bid ', '$ bidt',' $ bidl ','". $ _ SESSION ['id']. "', now ());";}
Else {

$ SQL = "update userlinks set title = '$ bidt', links =' $ bidl ', userid = '". $ _ SESSION ['id']. "', datetime = now () where id =' $ bid ';";
}



If (mysql_query ($ SQL )){
Echo "script" parent. location. reload (); script ";
} Else echo "script" parent. location. reload (); script ";


Exit ();


}





$ Bid = addslashes ($ _ GET ['id']);


$ Result = mysql_query ("SELECT * FROM userlinks where id = '". $ bid. "' and userid = '$ uid' order by datetime desc limit 1", $ link );
@ $ Row = mysql_fetch_row ($ result );





?>

The red code is. After I add data from the background, it is no problem to use update again; but it cannot be inserted. The above code is correct during local testing.

Set
If (mysql_query ($ SQL )){
Echo "script" parent. location. reload (); script ";
} Else echo "script" parent. location. reload (); script ";

Change
If (mysql_query ($ SQL )){
Echo "script" parent. location. reload (); script ";
} Else echo mysql_error (); // echo "script" parent. location. reload (); script ";
Look
Because you can say that the local server is OK, but not the server. Therefore, check the permissions first.
Since the background can be inserted, you should consider whether it is a program problem.

Okay. let me try. thank you !!

Zhenniu X! Solved. Admire!

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.