- Joined
- Feb 14, 2003
- Location
- Southeast US
tearing my hair out over this and is should be SO SIMPLE.
scenario: you have a table with columns that hold strings.
how do you search the table for values (exact entire values, not partial strings) and process a null result? This has to be possible, this forum and every forum uses something like it. If i search the forum subjects for some random hash I won't find it, and the ocforums scripts will tell me it wasn't found.
But i cannot for the life of me replicate it.
- i've tried num_rows = mysql_num_rows($result) figuring that i could then test $num_rows with if. if it's >0, there was a result. If it's <1 or not set, then there was no result. This didn't work. "invalid resource" messages.
- i've tried using a select count statement. This doesn't work either. "invalid resource messages."
- i've tried processing result with many different variations of possible boolean outcomes with many different variations of syntax (TRUE, FALSE, -1, 0, etc) to try to get the script to work, and nothing.
I spent all day yesterday fighting this and a large part of this morning. I joined forums and asked and haven't gotten good responses yet. I've done a ton of googling and can't find it.
mysql 5 and php5 with apache 2.22 is what i'm running, on freebsd.
So please, someone.
Write me some simple code based on the following:
assume schema appleschema and table appleowners
table appleowners -
ownerid int not null auto_increment primary key
ownername varchar(30)
please explain how to search the appleowners table for an already existing owner name, and how to process $result if it's not found.
scenario: you have a table with columns that hold strings.
how do you search the table for values (exact entire values, not partial strings) and process a null result? This has to be possible, this forum and every forum uses something like it. If i search the forum subjects for some random hash I won't find it, and the ocforums scripts will tell me it wasn't found.
But i cannot for the life of me replicate it.
- i've tried num_rows = mysql_num_rows($result) figuring that i could then test $num_rows with if. if it's >0, there was a result. If it's <1 or not set, then there was no result. This didn't work. "invalid resource" messages.
- i've tried using a select count statement. This doesn't work either. "invalid resource messages."
- i've tried processing result with many different variations of possible boolean outcomes with many different variations of syntax (TRUE, FALSE, -1, 0, etc) to try to get the script to work, and nothing.
I spent all day yesterday fighting this and a large part of this morning. I joined forums and asked and haven't gotten good responses yet. I've done a ton of googling and can't find it.
mysql 5 and php5 with apache 2.22 is what i'm running, on freebsd.
So please, someone.
Write me some simple code based on the following:
assume schema appleschema and table appleowners
table appleowners -
ownerid int not null auto_increment primary key
ownername varchar(30)
please explain how to search the appleowners table for an already existing owner name, and how to process $result if it's not found.