0
function get_subject_by_id($subject_id){
global $connection;
$query = "SELECT * ";
$query .= "FROM subjects ";
$query .= "WHERE 'id' ={$subject_id} ";
$query .= "LIMIT 1 ";
$result_set = mysql_query($query, $connection);
confirm_query($result_set);
// if no rows are returned fetch_array will return false
if(!is_null($result_set)){
echo "got here";
echo $result_set;
}
if($subject=mysql_fetch_array($result_set)){ // not working properly
echo "testing fetch array";
return $subject;
}else {
return NULL;
}
雖然我的表中有3個項目,但提取查詢仍然返回false。一些代碼顯然正在測試,看看我是否得到了結果,並且這些工作都正常,但是fetch數組並沒有執行if語句,因爲它認爲它是錯誤的。請幫助無奈的幾個小時屬於這個問題mysql提取數組保持返回false
感謝您分享,它更有意義,爲什麼它不會工作,這解決了我在客戶端的問題。謝謝。 – chacliff