With the following PHP code
$query = "INSERT into Index_base (cardid, name, sex, nationality, birth, address, issued, expiration) values ($cardid, $na Me, $gender, $folk, $birthday, $addr, $agency, $expire) "; mysql_query ($query); if ($buy = =" 1 ") {$bid = mysql_insert_id (); Echo ($bid), $time =date ("y-m-d", Time ()), $time. = ": 1"; $query = "INSERT into INDEX_B2A (bid, aid, ' limit ', now) VALUES ($bid, $aid, ' $time ', 1) ", Echo ($query); $result = MySQL ($query); Echo (" result ". $result); if (Mysql_affected_rows () ==1) Die (" 1 ") Else Die (" 0 ");}
Depending on the value returned by Echo and die, the request $query = "INSERT into INDEX_B2A (bid, aid, ' limit ', now) VALUES ($bid, $aid, ' $time ', 1)"; it should be exactly right, $res Ult is 1, and affected rows is also 1.
But in the database, there is no way to find the insertion of this article where.
I added an echo ($query), print out the request for insert into INDEX_B2A (bid, aid, ' limit ', now) VALUES (102631, ' 89 ', ' 2014-06-13:1 ', 1), direct input Mys QL, of course, is executed correctly, and when you refresh the database, you can see the inserted entries immediately.
Because limit is the keyword, I have added "as quotation marks."
To ensure that no errors are made, the 89 outside quotation marks are also removed, and the 2014-06-13:1 value is changed, and the trailing colon and the number 1 are removed.
Then execute:
MySQL is still in effect, PHP does not take effect, but the return value is said to be successful execution.
Don't know where the problem is?
Reply to discussion (solution)
$result = MySQL ($query); Is your custom function in MySQL ()? Or a hand mistake?
Echo Mysql_error (); See if there are any errors.
Did you enter the wrong library?
$result = MySQL ($query); What is this?
I also encountered the same problem, insert, update can not be completed.
I also encountered the same problem, insert, update can not be completed.
Looked up and did not find anything, and finally got a MySQL API document, find the segment code, change the corresponding field. It should be a question of the character of the statement (I don't know ...) )。
Attach my can insert code, you modify the content to try, hope to solve your problem:
$sql = "INSERT into Resell_info (ID, user, datetime, content) VALUES (null, ' 12345 ', null, ' 12345 ')"; mysql_query ($sql);
The second parameter of the mysql_query () function is preferably coupled with a
Running results of the posted program
Learn, learn, learn
mysql_query (query,connection);
It must be that you are not connected to the database.
In MySQL, the test can be successful, that means that the statement is not a problem. But the MySQL test, in fact, is in the state of the linked database.
But on the PHP page, the first thing you need to do is to connect to the database and add the connection parameters.