Jump to content

[SOLVED] SELECT AND error


forumnz

Recommended Posts

My code should select * from a db where something = something AND something LIKE....

 

Anyway, it basically ignore the addre as below:

 

What could be wrong?

 

$query = "SELECT * FROM cmads WHERE addre='5' AND keyw LIKE '%$trimmed%' OR buzzname LIKE '%$trimmed%' OR descr LIKE '%$trimmed%' OR sub LIKE '%$trimmed%'
  ORDER BY keyw"; 

 

Thanks,

Sam.

Link to comment
https://forums.phpfreaks.com/topic/83683-solved-select-and-error/
Share on other sites

[code]Use parenthesis:
[code]
SELECT * 
FROM cmads 
WHERE addre='5' AND 
  ( keyw LIKE '%$trimmed%' OR 
    buzzname LIKE '%$trimmed%' OR 
    descr LIKE '%$trimmed%' OR 
    sub LIKE '%$trimmed%'
  )
ORDER BY keyw

 

You will get dramatically different results depending on how you use them[/code][/code]

try it this way ok.

 

let me no if it works atleast cheers.

 

<?php 
$query = "SELECT * FROM cmads
WHERE addre='5' AND keyw 
LIKE '%".$trimmed."%' OR buzzname LIKE '%".$trimmed."%'
  OR descr LIKE '%".$trimmed."%' OR sub LIKE '%".$trimmed."%'
  ORDER BY keyw"; 
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.