Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
Trouble with MySQL command in script

Posted by Chris_Isaac (Chris Isaac), 20 February 2005

I've got the following command which isn't quite working:

$sql="select name, street, town, county, postcode from hotel,locations where town rlike \"^$cur\" and hotel.location = and email!=\"none\" and active=\"null\"";

The bit thats causing the problem is the Quote:
and active=\"null\"
bit.  Without it it works fine, ie produces a list where town name begins with $cur, the location is correct and there is a valid email acddress, I just don't follow why the last bit is failing.

Incidently 'active' is an int field, some are set to 1, 2, or 3. But its the majority which are still null which I want to grab.  I've also tried a few different options like Quote:
active !=1
which I would be happy with, but that didn't work either.

Any pointer greatly appreciated.

Posted by admin (Graham Ellis), 20 February 2005
I'm guessing it might relate to the NULL.   NULL is not normally a value that you write in quotes, but a condition, so typically:

Incorrect: active = "NULL"

correct: active IS NULL

Suggestion - try your query and perfect it through the mysql client program and then put it into your program.  At the very least this will tell you if you have an SQL or PHP issue.

Posted by Chris_Isaac (Chris Isaac), 20 February 2005
Perfect, thats fixed it.


This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: • WEB: • SKYPE: wellho