January 17th, 2000, 02:15 AM
My apologies for the length of this - it requires a bit of explanation. I have 2 databases. Database 1 is fully populated while db2 is not. When I list the contents of db1, I need to query a single field in db2. An id key links the 2 db's, allowing me to pull an ownership flag from db2 and apply it to db1. That field may be null, but it may also contain a zero or a one (I'm populating the db via a checkbox). I am trying to peel out that one and use it to set an icon when any contents of db1 are listed.
So far, I've tried the 'mysql_num_rows' but that pulls back all the ones plus all the zeroes - no good. I can differentiate between the data but, even though I get the results I want, I also get the '$xxx is not an object' message when I fetch and it hits nulls and blows up in the fetch. I've tried all sorts of if statement, isSets, and even tried to set all the non 1 data going into that field into nulls so I could use the num_rows, but, so far, zip.
I've looked at the mySQL forum and while there is a similar question, mine is a stop beyond. Also have been all through the PHP site plus my well worn copy of O'Reilly's "MySQL and mSQL"
The select statement currently looks like:
$stockquery=mysql_db_query('models',"select own from vehicles where not isnull(stock) and carID=$carID ");
Thanks for any help anyone could offer. And, again, sorry for the length.
January 17th, 2000, 06:59 AM
Maybe I'm missing something because this seems obvious. Instead of not isnull(stock) why not use where stock=1?
January 17th, 2000, 10:39 AM
Doh! I've been looking at this waaaay too long. I could feel there was an easy solution but just couldn't get it off the tip of my brain. Changed the selected, reverted back to the num_rows function and all is great. Thanks!