Why does this SQL statement always fail to be executed? $ idinfo = mysql_fetch_array (& quot; select * fromtb_yonghuwherename = '$ name' andid =' $ ID' & quot;) ordie (& quot; access failed & quot;); is the statement itself a problem? In addition, why does the $ name SQL statement always fail to be executed?
$ Idinfo = mysql_fetch_array ("select * from tb_yonghu where name = '$ name' and id =' $ ID'") or die ("access failed ");
Is the statement itself a problem? In addition, does $ name and $ id have to be enclosed in single quotes?
In the previous echo, both $ name and $ id have values, and they are the same as those in the database.
Why always show access failure?
Database connection should be okay, because if there is a problem, the database connection will fail.
------ Solution --------------------
Die ("access failed") indicates that "access failed" is displayed as long as mysql_fetch_array fails to be executed. Therefore, you cannot conclude that the database connection is correct.
------ Solution --------------------
Take a look at the manual. mysql_fetch_array is the execution resource, not a statement.
PHP code
$ Rs = mysql_query ("select * from tb_yonghu where name = '$ name' and id =' $ ID'") or die ("access failed "); $ idinfo = mysql_fetch_array ($ rs );
------ Solution --------------------
The SQL execution function is mysql_query (). you can check the next PHP_MANUAL on the official website first.
------ Solution --------------------
The manual must be carried with you...