SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2011
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error when asking for one parameter. No error when asking for all others!

    This is a very simple problem but very confusing. On line 128 I want to get productid and group but I get the following error message:

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/.../html/accessory.php on line 129

    IF I ASK FOR productid and code THERE IS NO ERROR MESSAGE. ie. If I ask for code intstead of group there is no problem. Infact if I ask for any field other than group it works! The error when asking for group occurs for line 129:



    PHP Code:
    LINE 128  $info mysql_query("SELECT productid,group FROM products WHERE categoryid = ".$selcat);
    LINE 129  while($row mysql_fetch_array($info)) {
    LINE 130   echo "<li><a href='accessory.php?product=".$row['productid']."'>".$row['group']."</a></li>"
    Anyone know what the problem could be?

    Matt.

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    72 Post(s)
    Tagged
    0 Thread(s)
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

    This line means "Your query screwed up. Check your query."

    PHP Code:
    LINE 128  $info mysql_query("SELECT productid,group FROM products WHERE categoryid = ".$selcat);
    LINE 129 echo mysql_error();
    LINE 130  while($row mysql_fetch_array($info)) {
    LINE 131   echo "<li><a href='accessory.php?product=".$row['productid']."'>".$row['group']."</a></li>"
    PS: group is a reserved word in mysql, and will need backtick escaping (`)


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
  •