How to assign a MySQL statement to a PHP variable
I have looked all over the web and cannot seem to find a proper way to assign the result of a MySQL query to a PHP variable. The code开发者_StackOverflow社区 that I currently have returns a "resource id #3" error. Here is what it looks like.
//Select the 'aQID' of the question that has it's BOOL set to "true"
$currentQ = mysql_query("SELECT aQID FROM approvedQuestions WHERE status='1'");
$cuQ = mysql_result($currentQ,1,"status");
echo $cuQ;
I know that the query will only ever return one record (the active question). But I cannot seem to figure out what function to use.
$currentQ = mysql_query("SELECT aQID FROM approvedQuestions WHERE status='1'");
$rs = mysql_fetch_array($currentQ);
var_dump($rs);
精彩评论