I have this line of script:
<?php
// List of cities in the state
$sql = "SELECT city, state ";
$sql .= "FROM {$tbl_prefix}shrimp_restaurants ";
$sql .= "WHERE {$tbl_prefix}shrimp_restaurants.state = '".$state."' AND {$tbl_prefix}shrimp_restaurants.show = '1' ";
$sql .= "UNION SELECT city, state ";
$sql .= "FROM {$tbl_prefix}shrimp_stores ";
$sql .= "WHERE {$tbl_prefix}shrimp_stores.state = '".$state."' AND {$tbl_prefix}shrimp_stores.show = '1' ORDER BY `city` ASC";
$query = mysql_query($sql) or die("SQL: $sql <br>".mysql_error());
$num_rows = mysql_num_rows($query);
But it is returning this when run:
SQL: SELECT city, state FROM 8_shrimp_restaurants WHERE 8_shrimp_restaurants.state = 'AK' AND 8_shrimp_restaurants.show = '1' UNION SELECT city, state FROM 8_shrimp_stores WHERE 8_shrimp_stores.state = 'AK' AND 8_shrimp_stores.show = '1' ORDER BY city ASC
You have an error in your SQL syntax near 'UNION SELECT city, state FROM 8_shrimp_stores WHERE 8_shrimp_stores.state = 'AK'' at line 1
What is ging wrong?