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!