I'm trying to use the following code to make a search on my website in the database, the goal is to return all columns in multiple tables that contain the search including the parent-table which I have included in as a column in the tables.
$schema = 'maps';
$search = '%'.$_GET["ident"].'%';
$query1 = "
select TABLE_NAME
from information_schema.tables
where TABLE_SCHEMA = '{$schema}'";
$result1 = mysql_query($query1);
$queryParts = array();
while($row = mysql_fetch_assoc($result1)) {
$table = $row['TABLE_NAME'];
$queryPart = "
select name, isin, parent
from `maps`.`{$table}`
where `isin` like '{$search}'
";
$queryParts[] = $queryPart;
}
$unionQuery = implode(' union all ', $queryParts);
$result2 = mysql_query($unionQuery);
and echo using:
while($row = mysql_fetch_array($result2))
{
$f1 = $row['name'];
$f2 = $row['parent'];
}
I get the following error
mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\home\security.php on line 55