categoria (id, nome_cat, imagem)
tutorial (id_tuto, id_cat, titulo, tutorial, data, hora)
Eu fiz o sistema de busca apenas na tabela tutorial pra testar e deu tudo certo ..
Mas na hora que eu trabalho com as duas tabelas pra pode imprimi o resultado da busca dessa forma:
nome_cat da tabela CATEGORIA e titulo da tabela TUTORIAL na mesma pagina ... ele dá um erro
Aqui estão os arquivos que eu criei:
busca.html
<form method="POST" action="resultado.php?act=buscar"> <table cellpadding="0" cellspacing="0" width="450"> <tr> <td width="75" Class="texto" align="right">Buscar Tuto:</td> <td width="1" Class="texto"> </td> <td width="384" Class="texto"> <input type="text" name="texto" size="23" Class="text"></td> </tr> <tr> <td width="75" height="2" Class="texto"></td> <td width="1" height="2" Class="texto"></td> <td width="384" height="2" Class="texto"></td> </tr> <tr> <td width="75" Class="texto" align="right">Em:</td> <td width="1" Class="texto"> </td> <td width="384" Class="texto"><select size="1" name="em"><option value="titulo">Titulo</option><option value="tutorial">Tutorial</option></select></td> </tr> </table> <input type="submit" value="Adicionar" name="Adicionar" Class="text"> <input type="reset" value="Limpar" name="Limpar" Class="text"></form>
resultado.php
<? include "config.php"; $act = $_GET['act']; $frase = $_POST['frase']; $em = $_POST['em']; $palavra = str_replace(" ", "%", "$frase"); if("$act" == "buscar"){ $query = mysql_query("SELECT * FROM tutorial as t, categoria as c WHERE 'c.id' = 't.id_cat' and WHERE '$em' LIKE '%$palavra%' ORDER BY 'id_tuto' DESC LIMIT 5") or die(mysql_error()); while($mostra = mysql_fetch_array($query)) { $titulo = $mostra['titulo']; $nome_cat = $mostra['nome_cat']; echo "$titulo $nome_cat<br>"; } } ?>
Como vocês podem ver eu estou trabalhando com as duas tabelas ...
Bom o erro que retorna é o seguinte:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE 'tutorial' LIKE '%%' ORDER BY 'id_tuto' DESC LIMIT 5' at line 1
Se alguem puder me ajudar ...
Obrigado!

Edição feita por: auei, 03/06/2006, 09:19.