'Query was empty' ???

Discussion in 'PHP' started by CuBz, Aug 14, 2010.

  1. #1
    Sorry for making a new thread but I really need to sort this ASAP.

    My page is showing "Query was empty" and nothing else.

    Here is the part of the code on the page that displays this...

    $oc_id=strip_tags($_GET['oc_id']);
    if (strip_tags($_GET['place']) == "we"){
    $use="we_inv";
    $a="we";
    $getit="SELECT * FROM oc WHERE we_inv='$username' AND id='$oc_id'";
    }elseif (strip_tags($_GET['place']) == "ee"){
    $use="ee_inv";
    $a="ee";
    $getit="SELECT * FROM oc WHERE ee_inv='$username' AND id='$oc_id'";
    
    }elseif (strip_tags($_GET['place']) == "driver"){
    $use="driver_inv";
    $a="driver";
    $getit="SELECT * FROM oc WHERE driver_inv='$username' AND id='$oc_id'";
    }
    
    $round=mysql_query($getit) or die(mysql_error());
    $check=mysql_num_rows($round);
    
    if ($check != "0"){
    mysql_query("UPDATE `oc` SET `$a`='$username' WHERE `id`='$oc_id'");
    mysql_query("UPDATE `users` SET `oc`='1' WHERE `username`='$username'");
    echo "<SCRIPT LANGUAGE='JavaScript'>
    window.location='oc.php';
    
    </script>";
    }
    PHP:
    Thanks in advance
     
    CuBz, Aug 14, 2010 IP
  2. jpratama

    jpratama Member

    Messages:
    31
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #2
    I just took a glance of your PHP code and I might find something in all your query statement. You might use the quotes incorrectly because single quote won't translate the variable but its name. You can do this :
    "SELECT * FROM oc WHERE we_inv= $username AND id=$oc_id"
    PHP:
    or
    "SELECT * FROM oc WHERE we_inv='" . $username . '" AND id='" . $oc_id . "'"
    PHP:
    Hope it helps.
     
    Last edited: Aug 14, 2010
    jpratama, Aug 14, 2010 IP