Query returns error

Discussion in 'MySQL' started by mipa jim, Jul 24, 2006.

  1. #1
    I'm on my last stage and I can't get this query to work. Returns error

                                          $query4 = "SELECT from categories where(categories = '$category')";
    				                      $result4 = mysql_db_query($db, $query4);
    				                      $r = mysql_fetch_array($result4);
    				                      $bodydescrip = $r["bodydescrip"];
    
    Code (markup):
    I'll be the first to admit I have no clue how to do. SO as I always do I've been trying to modify something until I can get it to work.. but not this time..

    thks for any help
     
    mipa jim, Jul 24, 2006 IP
  2. tflight

    tflight Peon

    Messages:
    617
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The error you received typically means that your query returned no records (results) but that you then went on to try and use the result of that query... which it can't do since there wasn't a result.

    So you should check to see why the query isn't returning any results.
     
    tflight, Jul 24, 2006 IP
  3. GeorgeB.

    GeorgeB. Notable Member

    Messages:
    5,695
    Likes Received:
    288
    Best Answers:
    0
    Trophy Points:
    280
    #3
    Replace: $query4 = "SELECT from categories where(categories = '$category')";
    With: $query4 = "SELECT from categories where categories='$category'";

    Then check your DB and ensure that
    - categories is an actual table in the DB
    - categories is an actual field within the table called categories

    Try not to use the exact same name for everything :)
     
    GeorgeB., Jul 30, 2006 IP
  4. mipa jim

    mipa jim Peon

    Messages:
    261
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks George,

    I actually resolved this a few days ago. I didnt pick the names ... that is the way the script was written that I am working with... that may the worst case scenerio in the whole thing.. all the other category fields at least have a number beside them..
     
    mipa jim, Jul 30, 2006 IP