I am trying to write a query that gets a list of trains from my database, the user will enter the real name and the first query will get the code for the station or 'tiploc' and then use it in the second query. For some reason i am not getting anything back, I am certain that it is to do with data the is gotten from the fetch as it works fine if I hardcode the tiploc. I am fairly weak at php so any help would be great! Thanks

```
<?
 mysql_connect("localhost","root","XXXXXX")
or die ("No connection could be made to the OpenRail 
Database");mysql_select_db("autotrain");

$query1 = "SELECT tiploc_code FROM allstations WHERE c LIKE 'Cradley Heath';";

$result1 =mysql_query($query1);

$tiploc=null;
while($row = mysql_fetch_assoc($result1)){
$tipoc=$row['tiploc_code'];

}
$query2 = "SELECT allstations.C, locations.public_departure
FROM `locations` , allstations, schedules_cache,schedules
WHERE locations.id = schedules_cache.id
AND schedules_cache.id = schedules.id
AND '2012-11-11' BETWEEN schedules.date_from AND schedules.date_to
AND locations.tiploc_code = '$tiploc'
AND locations.public_departure >=1600
AND locations.public_departure <=1700
AND schedules.runs_su LIKE '1'
AND schedules_cache.destination = allstations.tiploc_code
ORDER BY locations.public_departure ASC;";

$result2=mysql_query($query2);

while($row = mysql_fetch_assoc($result2)){
echo($row['C']);

}
?>

```