I am making a simple search system that only brings the result amounts of the specified tables. The problem is that it is causing an error because the tables are different and their lines are different. See my script.
$q = $_GET['busca'];
$query= '
SELECT * FROM noticia WHERE noticia_title LIKE "%'.$q.'% or noticia_content LIKE "%'.$q.'%"
UNION
SELECT * FROM eventos WHERE evento_nome LIKE "%'.$q.'% or evento_content LIKE "%'.$q.'%"
UNION
SELECT * FROM albuns WHERE album_name LIKE "%'.$q.'%" or album_descricao LIKE "%'.$q.'%"
';
$result = mysql_query($query);
$count = mysql_num_rows($result);
if ($count == 0) {
echo "Nenhum resultado!";
} else {
if ($count == 1) {
echo "1 resultado encontrado!";
}
if ($count > 1) {
echo "$count resultados encontrados!";
}
while ($dados = mysql_fetch_array($query)) {
echo "";
}
}
The error that is being caused is: Warning: mysql_num_rows (): supplied argument is not valid MySQL result resource in
Can anyone help me?