我正在嘗試執行以下PHP/MySQL查詢,並且它對前兩個組工作正常,但對於其他所有人,我都會收到MySQL錯誤,請問這是正確寫入的嗎?與MySQL查詢問題,編碼錯誤?
$user =& JFactory::getUser();
$N = $user->get('name');
$username = $user->get('username');
$groups = $user->get('groups');
foreach($groups as $groupName=>$groupId)
{
}
$G=$groupName;
if ($G=="Management Staff")
$result = mysql_query("SELECT * FROM hqfjt_chronoforms_data_addupdatelead");
elseif ($G=="Website Developers")
$result = mysql_query("SELECT * FROM hqfjt_chronoforms_data_addupdatelead");
else
$result = mysql_query("SELECT * FROM hqfjt_chronoforms_data_addupdatelead WHERE createdby=$N");
當我登錄,別人我得到:
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\server2go\server2go\htdocs\chandlers\components\com_jumi\views\application\view.html.php(38) : eval()'d code on line 87
Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in C:\server2go\server2go\htdocs\chandlers\components\com_jumi\views\application\view.html.php(38) : eval()'d code on line 132
你會得到什麼錯誤? – 2011-12-28 23:22:15
我已將它添加到 – 2011-12-28 23:25:33
錯誤所引用的對'mysql_fetch_object'的調用在哪裏?我在上面的代碼片段中看不到'mysql_fetch_object'的調用。它是否在'$ result'的這個塊之後出現?如果是這樣的話,似乎'$ result'沒有被設置。 – Batkins 2011-12-28 23:29:17