English 中文(简体)
我sql_fetch_assoc()预计,参数1是资源,由[复制]提供蓝色。
原标题:mysql_fetch_assoc() expects parameter 1 to be resource, boolean given [duplicate]
  • 时间:2011-10-09 22:23:28
  •  标签:
  • php
  • sql

我最近把我的购买力平价版本升级到我的东道国,我认为这造成了这一错误。 每当我开始点火时,这包括要求档案进入数据库,便开始产生GIGABYTES的错误。 我看到该日志,我收到这一错误。

PHP 警告:mysql_fetch_assoc()预计参数1为资源,Boolean given in /var/www/html/includes/database.config.php on line 22

第22条

while(($c = mysql_fetch_assoc($rsetCoupons)) !== false)

我猜测,它将在列出的每一个地方产生这一错误。

是否有任何人认为可以造成这种情况? 现行购买力平价版本。

P 5.3.2 (cli) (built: Jun 25 2011 08:12:19)

Copyright (c) 1997-2010年PHP Group

Zend Trust v2.3.0, 版权(c) 1998-2010 Zend Technologies

(显然,我删除了代码一开始连接的变量)

@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;
    }
}
最佳回答

当时执行时,单单Co不是我的怀疑资源。 您的询问都失败了,或者变数正在某个地方消失。

http://php.net/mysql_fetch_assoc

我相当确信,你们的问话失败了。 您应检查我的验尸,如果是假的,则检查我的验尸。

另外,你也不应压制我方ql_link和我sql_select_db电话中的错误。 如果无法建立数据库链接,那么你就应当处理这一更令人宽慰的问题,而不是让你在随后的每一次我的呼声上打上和错误的网页。 这实际上可能是你的错误。 如果你重新制止错误,把错误从用户中隐藏起来,那么面对PHP网站的公众就应当展示_器,但你还是应当发现错误。

问题回答

答案是(常常)你的请求是错误的。

在此情况下,你使用<代码>$rsetCoupons = query(SlectT * from marons ORDER BY maron_id ASC );,然后是我的sql功能,使用mysql_query





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签