The SQL statement on the php page is successfully executed. if the database is not updated, I create a page about voting. the database connection is successful. The following is the method for executing the SQL statement. no error is returned for the query. 2 is returned, however, the database data is not updated.
However, if the SQL statement is executed successfully in phpmyadmin, the data can also be updated.
$ SQL = "update vote set num = num + 1 where name = 'Bush '";
Public function execute_dml ($ SQL) {$ B = mysql_query ($ SQL, $ this-> conn) or die ("execution failed! ". Mysql_error (); if (! $ B) {return 0; // execution failed} else {if (mysql_affected_rows ($ this-> conn)> 0) {return 1; // execute OK} else {return 2; // it indicates that no row is affected }}}
I think the code should be okay. it should be another problem.
Reply to discussion (solution)
If not, it may be encoding. For example, 'Bush 'is the UTF-8 code on the page and the database is GBK.
We recommend that you use primary key query to ensure uniqueness.
Encoding problem. what is the encoding of your table? have you executed the set names utf8 statement.
If not, it may be encoding. For example, 'Bush 'is the UTF-8 code on the page and the database is GBK.
We recommend that you use primary key query to ensure uniqueness.
The primary key query is successful. Thank you. Ah, I don't know much about mysql databases.