Jump to content

Syntax Error when combining AND and OR


Pi_Mastuh

Recommended Posts

I am trying to run a select query, and am not sure why I'm getting a syntax error.

 

$SQL2 = "SELECT * FROM messages WHERE to='$username' OR (to='ALL' AND busID='$busID')";
	$result = mysql_query($SQL2,$connection) or die(mysql_error());

 

"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 'to='lynsey93' OR (to='ALL' AND busID='1')' at line 1"

 

Could anybody shed some light on the situation?

Link to comment
https://forums.phpfreaks.com/topic/225563-syntax-error-when-combining-and-and-or/
Share on other sites

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.