My query goes like this:
SELECT * FROM database WHERE table1 LIKE '%$ingr%' OR table2 LIKE '%$ingr%'
Any suggestions?
bzctoons - 15 Jan 2005 15:18 GMT
mdalene a écrit :
> My query goes like this:
>
> SELECT * FROM database WHERE table1 LIKE '%$ingr%' OR table2 LIKE '%$ingr%'
>
> Any suggestions?
mhh...
I think :
SELECT * FROM table WHERE field1 LIKE '%$ingr%' OR field2 LIKE '%$ingr%'
Ianm - 19 Jan 2005 00:49 GMT
Try protecting your variables.....
$ingr is probably being matched!!
therefore try this:
"SELECT * FROM table WHERE field1 LIKE '%" . $ingr . "%' OR field2 LIKE
'%".$ingr."%'";
------ actual code (which assumes you've already connected to the DB)
$sql = "SELECT * FROM table WHERE ";
$sql .= "field1 like '%".$ingr."%' or ";
$sql .= "field2 like '%".$ingr."%'";
$result = mysql_query($sql, $dbcnx);
while ($row = mysql_fetch_row($result)) {
etc...........
daniele - 26 Jan 2005 12:46 GMT
Are you sure the SQL syntax is right ?
it's should be
SELECT * FROM tableNameWHERE fieldName1 LIKE '%$ingr%' OR fieldName2 LIKE '%$ingr%'
Have a nice day

Signature
dott. daniele galiffa
multimedia designer & developer
Macromedia Flash MX Developer Certified
daniele@mentegrafica.it
> My query goes like this:
>
> SELECT * FROM database WHERE table1 LIKE '%$ingr%' OR table2 LIKE '%$ingr%'
>
> Any suggestions?