title: Mysql SELECT with WHERE clause not working with variable
body: <p>I am pulling my hair out. I have two SELECT statements that are basically the same principal. The first one is working and the second one will not work with the WHERE clause in it. I need some fresh eyes and suggestions. I have been on every forum and read every post and have tried many "solutions" to no avail.  Hoping someone will see something I have missed.</p>
  
  <pre><code>$oID = zen_db_prepare_input($_GET['oID']);
  
    // Color coding for invoice -Start queries---
  
    $query = "SELECT * FROM cart1_orders WHERE orders_id = $oID";
    $result = $db-&gt;Execute($query); 
    $shiploc = $result-&gt;fields['shipping_method'];
    if ($result-&gt;RecordCount() &gt; 0) { 
    echo 'Test Query: = ' . $result-&gt;fields['shipping_method']; 
    } else { 
    echo 'Sorry, no record found for product number ' ; 
    }  
  
    $sql = "SELECT * FROM cart1_store_locations  WHERE pickup_name= $shiploc";
    $results = $db-&gt;Execute($sql); 
    $newcolorblock = $results-&gt;fields['color_code'];
    if ($results-&gt;RecordCount() &gt; 0) { 
    echo 'Color Query: = ' . $results-&gt;fields['color_code'];
    echo 'Location: = '. $results-&gt;fields['pickup_name']; 
    } else { 
    echo 'Sorry, no record found for Color Code ' ; 
    }  
  </code></pre>
  
  <p>Thank you in advance for your help and suggestions hopefully you will be able to see something I can't.</p>
  
  <p>First query results: Test Query: = Store Pickup (Mooresville - Gold's Gym)
  Second query results: WARNING: An Error occurred, please refresh the page and try again.</p>
  
  <p>If the WHERE clause is removed it returns values but not the correct ones. I need the WHERE statement for it to pull the correct information.</p>
  
  <p><strong>ANSWER</strong> kindly provided by bloodyKnuckles :)</p>
  
  <pre><code>$sql= "SELECT * FROM cart1_store_locations WHERE pickup_name= $shiploc";
  </code></pre>
  
  <p>changed to: (Needed to be escaped to comp for 's in the table data)</p>
  
  <pre><code>$shiploc_escaped = mysql_escape_string($shiploc);
  $sql = "SELECT * FROM cart1_store_locations  WHERE pickup_name=       '".$shiploc_escaped."'";
  </code></pre>
  
  <p>I have not used this forum before. LOVE IT!!! Thank you everyone!</p>