title: Query gives different result when run from site
body: <p>I am running a search on a database, to find cruises that contain a stop a port that has been entered in a search field. So a user types 'Dublin' and they get back all the cruises that stop there.</p>
  
  <p>I have two tables, cruises which contains all the cruises and itinerary which contains the stops on the cruise. they are related by cruises.id and itinerary.cruise_id</p>
  
  <p>The query I have run in MySQL workbench looks like this, I put Amsterdam in as an example of what is searched for</p>
  
  <pre><code>SELECT id, title, code FROM cruises WHERE EXISTS (SELECT * FROM itinerary WHERE port LIKE '%amsterdam%' AND cruises.id = cruise_id)
  </code></pre>
  
  <p>obviously in my web page, I have used </p>
  
  <pre><code>SELECT id, title, code FROM cruises WHERE EXISTS (SELECT * FROM itinerary WHERE port LIKE %s AND cruises.id = cruise_id)
  </code></pre>
  
  <p>THe workbench query does exactly what I want, returns eight cruises , all stopping at Amsterdam</p>
  
  <p>The web query returns eight matches, but they are all the same record ?</p>
  
  <p>Any ideas ?</p>
  
  <p>thanks</p>
  
  <p>Rich :)</p>
  
  <p>OK here's the code at the top of the page getting the search variable and doing the query</p>
  
  <pre><code>$colname_search = "-1";
  if (isset($_POST['search'])) {
   $colname_search = $_POST['search'];
  }
  
  $query_search_cruises = sprintf("SELECT id, title, code FROM cruises WHERE EXISTS     (SELECT * FROM itinerary WHERE port LIKE %s AND cruises.id = cruise_id )",     GetSQLValueString("%" . $colname_search . "%", "text"));
  $search_cruises = mysql_query($query_search_cruises, $connection) or die(mysql_error());
  $row_search_cruises = mysql_fetch_assoc($search_cruises);
  $totalRows_search = mysql_num_rows($search_cruises);
  </code></pre>
  
  <p>And this bit is doing the output. </p>
  
  <pre><code>&lt;h2&gt;&lt;?php if($row_search_cruises["title"]) { echo "Your search for \"" . $_POST['search'] . "\"was found here.."; } else { echo "Sorry no matches have been found"; } ?&gt;&lt;/h2&gt;
  &lt;?php do { ?&gt;
  &lt;p&gt;&lt;?php echo "&lt;a href=\"cruise_details.php?id=" . $row_search_cruises["id"] . "\"&gt;{$row_search_cruises['code']}, {$row_search_cruises['title']}&lt;/a&gt;"; ?&gt; &lt;/p&gt;&lt;br /&gt;
  &lt;?php } while ($row_search = mysql_fetch_assoc($search_cruises)); ?&gt;
  </code></pre>