Return empty set

Discussion in 'Databases' started by gw32, Jul 17, 2011.

  1. #1
    I am getting an empty set from this code.
    
    $query  = mysql_query("select a.im_name, b.name, a.description from images a, department b where a.dpt_id = b.dpt_id and a.dpt_id = '$pid' LIMIT 0, 30 ;") or die(mysql_error());
    
    while($row = mysql_fetch_array($query))
    {
    echo "$row['im_name']";
    }
    
    Code (markup):
    The echo does not appear.

    If I put the select statement in MySQL it works perfectly.

    Any help would be appreciated.
    Thank you
     
    gw32, Jul 17, 2011 IP
  2. plog

    plog Peon

    Messages:
    298
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #2
    How do you know what the SELECT statement is to put into MYSQL? To make sure the SQL statement you are intending to run is the one you are actually running I would echo out this:

    "select a.im_name, b.name, a.description from images a, department b where a.dpt_id = b.dpt_id and a.dpt_id = '$pid' LIMIT 0, 30 ;"
    PHP:
    Once you echo that out paste it into MYSQL and see if its runs. My guess is that $pid is not what you think it is.
     
    plog, Jul 18, 2011 IP
  3. gw32

    gw32 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have the DB working perfectly. Just having trouble outputting the XML string correctly.

    Thanks for all your help.
    Gordon
     
    gw32, Jul 18, 2011 IP