No error is returned for the mysql insertion request of PHP, but the database has not updated this post. the following PHP code $ query & nbsp is edited by dimply at 2014-06-1321: 46: 24; & nbsp; insert & nbsp; into & nbsp; index_base & nbsp; (cardid, & nbsp; name, & PHP's mysql insertion request returns no error, but the database is not updated
This post was last edited by dimply at 21:46:24
The following PHP code is provided:
$ Query = "insert into index_base (cardid, name, sex, nationality, birth, address, issued, expiration) values ($ cardid, $ name, $ 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 is". $ result );
If (mysql_affected_rows () = 1) die ("1 ");
Else die ("0 ");
}
According to the values returned by echo and die, the request $ query = "insert into index_b2a (bid, aid, 'limit', now) values ($ bid, $ aid, '$ time ', 1) "; it should be completely correct, $ result is 1, and affected rows is also 1.
However, in the database, I cannot find the inserted path.
I added an echo ($ query). The printed request is insert into index_b2a (bid, aid, 'limit', now) values (102631, '89 ', '2017-06-13', 1). enter mysql directly. of course, the execution is correct. after refreshing the database, you can immediately see the inserted entries.
Because limit is a keyword, I have added ''as a quotation mark.
To ensure that no error is caused, the quotation marks outside 89 are also removed. The value: 1 is also changed, and the colon and number 1 are removed.
Then execute:
It still takes effect in mysql, but does not take effect in php, but the returned values indicate that the execution is successful.
I don't know where the problem is?
------ Solution --------------------
$ Result = mysql ($ query); is mysql () your custom function? Or by mistake?
Echo mysql_error (); to see if there are any errors.
------ Solution --------------------
$ Result = mysql ($ query); what is this?