Variable in a mysql query
<pre><code>for ($i=0; $i&lt;$count; $i++) {
    $appid = $chk[$i];


    include "dbconnect.php";
    $selectquery = mysql_query("SELECT * FROM regform_admin WHERE tid = '$appid'");
    $fetch = mysql_fetch_array($selectquery);
    $tid = $fetch['tid']; $username = $fetch['username']; $c_month = $fetch['month']; $c_day =$fetch['day']; $c_year = $fetch['year'];
    $c_month2 = $fetch['month2']; $c_day2 =$fetch['day2']; $c_year2 = $fetch['year2']; 
    $pickup = "".$c_month."/".$c_day."/".$c_year."";
    $return = "".$c_month2."/".$c_day2."/".$c_year2."";
    $pickuploc = "".$fetch['pickupret']." "." ".$fetch['speclocation']."";
    $desti = "".$fetch['destination']." "." ".$fetch['location']."";
    $vehicle1 = $fetch['vehicle1'];
    $datesent = date("n j, Y; G:i"); ;
    $rand = rand(98765432,23456789);

    include "vehicledbconnect.php";
    $vquery = mysql_query("SELECT * FROM vehicletbl WHERE vehicle = '$vehicle1'");
            $getvquery = mysql_fetch_array($vquery);
            $maxcars = $getvquery['maxcars'];
            $carsleft = $getvquery['carsleft'];
            if ($carsleft == 0) {
            echo '
        &lt;script language="JavaScript"&gt;
        alert("Cannot move reservation to Pending for payment status. No available vehicles left for this reservation.");
        &lt;/script&gt;';

        echo "$vehicle1";

            }
</code></pre>

<p>Hi guys my problem here is that the $vehicle is not returning its values if it is inserted in a database query ($vquery = mysql_query("SELECT * FROM vehicletbl WHERE vehicle = '$vehicle1'");) but if it is echoed, it return its value. The logic here is that it will select all the values from vehicletbl wherein the value of any values in 'vehicle' column will be equal to the $vehicle1. Thanks for the help!</p>
