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
Trouble with MySQL command in script

Posted by Chris_Isaac (Chris Isaac), 20 February 2005
Hi

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

Code:
$sql="select name, street, town, county, postcode from hotel,locations where town rlike \"^$cur\" and hotel.location = locations.id 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.

Thanks.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk 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., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho