What is the problem of this mysql syntax? I copied it to phpmyadmin and it worked flawlessly. When I tried to fetch the array from php but it returned a "bool(false)" error.
(
SELECT
id,
cim,
'news' as kat
FROM
mbsz_news
WHERE
cim LIKE '%anystring%'
OR lead LIKE '%anystring%'
OR content LIKE '%anystring%'
)
UNION
(
SELECT
id,
p_name,
'plaza' as kat
FROM
mbsz_plazas
WHERE
p_name LIKE '%anystring%'
OR uzemelteto LIKE '%anystring%'
)
UNION
(
SELECT
id,
cim,
'book' as kat
FROM
mbsz_konyvtar
WHERE
cim LIKE '%anystring%'
OR kszam LIKE '%anystring%'
OR kiado LIKE '%anystring%'
)
PHP code:
$res = mysql_query($sql);
while($row = mysql_fetch_array($res))
{
echo $row['type'];
}
$res
gives the error bool(false)
Thanks for your help.
mysql_error()
return anything? If not, it's not a mysql error. Either no results or a PHP error. – AndrewR Sep 13 '12 at 14:47