Forum Moderators: open
I'm new to MySQL but am getting there. Here's a strange problem I'm having.
I create the MySQL queries in PhpMyAdmin, testing them off the actual database the site uses. This way I've found right away if things work or not. And so far, this method has worked perfectly.
However, tonight I have a problem.
I got this query to work in PhpMyAdmin. But when I put it into the web page as part of a script, it comes up with :
"Query was empty"
This is the actual SQL query that is working in PhpMyAdmin.
SELECT * FROM `table_name` WHERE productgroup = "product_group1" AND brand = "selected_brand" OR productgroup = "product_group2" AND brand = "selected_brand" ORDER BY rand() LIMIT 6
And this is the code I'm using for the query:
$sql = 'SELECT * FROM `table_name` WHERE productgroup = "product_group1" AND brand = "selected_brand" OR productgroup = "product_group2" AND brand = "selected_brand" ORDER BY rand() LIMIT 6';
Any ideas on what I'm doing wrong?
Thanks.
Jim