我最近在我的主機上升級了我的PHP版本,我認爲它導致了這個錯誤。每當我啓動apache並調用這個包含文件來訪問數據庫時,apache就開始產生錯誤的GIGABYTES。我查看日誌,我收到此錯誤mysql_fetch_assoc()期望參數1是資源,布爾給出
PHP的警告:mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /var/www/html/includes/database.config.php on line 22
線22
while(($c = mysql_fetch_assoc($rsetCoupons)) !== false)
我猜測它會產生這一列出的每個地方的錯誤。
有沒有人有任何想法可能會導致此?目前的PHP版本是
PHP 5.3.2(CLI)(建:2011年6月25日8點12分十九秒)
版權所有(C)1997-2010的PHP集團
Zend引擎V2.3.0,版權所有(C)1998-2010 Zend技術
(很明顯,我切出的變量來連接的代碼的開頭)
@mysql_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD);
@mysql_select_db(MYSQL_DATABASE);
define('DOMAIN', 'MYDOMAINISTHIS.com');
$parse_version = queryFetch('SELECT version,secret FROM version ORDER BY version_id DESC LIMIT 0,1');
$VERSION = $parse_version['version'];
$SECRET = $parse_version['secret'];
$VALID_COUPONS = array();
$rsetCoupons = query('SELECT * FROM coupons ORDER BY coupon_id ASC');
while(($c = mysql_fetch_assoc($rsetCoupons)) !== false)
{
$VALID_COUPONS[$c['code']] = $c['percent'];
}
$salutations = array();
$rsetSalutations = query('SELECT * FROM salutations ORDER BY salutation_id ASC');
while(($c = mysql_fetch_assoc($rsetSalutations)) !== false)
{
$salutations[] = $c['salutation'];
}
$BASE_PRICE_QTY = array();
$UPGRADE_PRICE = array();
$rsetPrices = query('SELECT * FROM cart_prices ORDER BY qty ASC');
while(($c = mysql_fetch_assoc($rsetPrices)) !== false)
{
$BASE_PRICE_QTY[] = $c['unit_price'];
$UPGRADE_PRICE[] = $c['upgrade_price'];
}
function insert($hash, $table)
{
$fields = implode(',', array_keys($hash));
$values = implode('","', $hash);
$query = sprintf('INSERT INTO %s (%s) VALUES("%s")', $table, $fields, $values);
query($query);
}
function query($query)
{
return @mysql_query($query);
}
function queryFetch($query)
{
return @mysql_fetch_assoc(query($query));
}
function p($key, $default = '')
{
if (isset($_POST[$key]))
{
return $_POST[$key];
}
else
{
return $default;
}
}
function g($key, $default = '')
{
if (isset($_GET[$key]))
{
return $_GET[$key];
}
else
{
return $default;
}
}
@bažmegakapa:感謝您的照顧,至少有一點更加規範。非常感激。 – hakre