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
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho