I'm trying to query a single result from two tables in my database. Here is my code:
$pageid = mysql_real_escape_string($_GET['id']);
$query = sprintf("(SELECT * FROM classifieds WHERE pageid = '$pageid' LIMIT 1)
UNION ALL
(SELECT * FROM resumes WHERE pageid = '$pageid' LIMIT 1)");
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
echo $row['title'] . "<br/>";
}
pageid
is a URL variable. This code is trying to use that variable, query the database with it, and return the result. I get this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
Hitting a wall here. Can't figure out why this error keeps happening. Any help == thanks.