SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    May 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\

    Changed to Php5.3 and receiving these warning messages,

    Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\wamp\www\050505\fnc2.php on line 322

    I think it's saying that ($sql_res) needs to be a resource and not a boolean on line 322.

    ----------------------------------------

    function get_cat_count($ct)
    {
    // This function return how many ads exist in the specified category
    global $cat_fields, $table_ads, $page, $adsonpage;


    $sql_query="select count(idnum) from $table_ads where
    catname='$ct' and visible=1";

    $sql_res=mysql_query("$sql_query");
    $row=mysql_fetch_row($sql_res); // line 322
    $count=$row[0];
    return $count;
    }


    How do I create a resource from this boolean?
    Thanks for your replies,

  2. #2
    SitePoint Zealot Jaanboy's Avatar
    Join Date
    Sep 2007
    Location
    UK
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It means that mysql_query isn't returning a resource but instead returning false, meaning that there is an error in your sql code.

    Use the following code and see what error you get:

    PHP Code:
    $sql_res mysql_query($sql_query) or die (mysql_error()); 

  3. #3
    SitePoint Member
    Join Date
    May 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I included code on line 321 the above code and an now receiving the following message,

    you have an error in your SQL syntax;
    check the menual that corresponds to your MySQL server version for the
    right syntax to use near 'where catname='Elec' and visible = 1'at line 1

  4. #4
    SitePoint Zealot zalucius's Avatar
    Join Date
    Jul 2007
    Location
    Denmark
    Posts
    162
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have an error in your SQL query.
    Echo the query, and see if you can spot the error... which is just before the "WHERE" clause.
    zalucius


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •