Link to home
Start Free TrialLog in
Avatar of tonyhhisc
tonyhhisc

asked on

Whats' wrong with this query?

$ins_result = mysql_query("SELECT * FROM users WHERE guest_faculty!='1' AND (faculty_courses LIKE '%,".$currUserCourse.",%' OR instructor_courses LIKE '%,".$currUserCourse.",%') ORDER by instructor_courses DESC");

while ($row = mysql_fetch_array($ins_result)) {
  $row['ID'];
}


I'm getting this error:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /var/www/vhosts/******/******/*****/httpdocs/sidebar_instructor.php on line 18

Line 18 is the "while()" line.

Thanks!
Avatar of rerard
rerard
Flag of United States of America image

The query is surrounnded by double quotes, and then you also have double quotes in the query itself.
escape the quotes with a \ ...  check this out:

http://php.net/manual/en/language.types.string.php
ASKER CERTIFIED SOLUTION
Avatar of Frosty555
Frosty555
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tonyhhisc
tonyhhisc

ASKER

Thanks a lot Frosty you rock!!!

(by the way, it was just a stupid error on my part.... guest_courses was not a field in the database -- I'm in panic mode here as we did an upgrade and working through PHP errors everywhere!!)

Cheers!
I can't count the number of times this has happened to me. Dying properly on error, and printing out your SQL statements always makes the debugging process much easier. Glad to help :)