Forum Moderators: open

Message Too Old, No Replies

Select Statement With 2 Accepted Values

Echo statement allowing both values

         

oceanwave

2:40 pm on Oct 4, 2007 (gmt 0)

10+ Year Member



Hi,

I have a query that looks like this:

$result = @mysql_query("SELECT count(id) FROM members WHERE pass='$_POST[pass]' AND name='$_POST[user]' AND activated='1' AND expired > curdate()")
or die("Couldn't query the user-database.");

Later on in the script I have this:

if ($activated == "1") {
echo ("You will be redirected to your appropriate section in 3 seconds.")

Works like a charm as my login. Now I wanted to add if activated='2' the person will be directed to the same page. I think I have to change the first line of code to...

$result = @mysql_query("SELECT count(id) FROM members WHERE pass='$_POST[pass]' AND name='$_POST[user]' AND activated='1' OR activated='2' AND expired > curdate()")
or die("Couldn't query the user-database.");

Is this the correct syntax to use? Guess I should also LIMIT it to 1 since there should only be one row pulled.

Now I have tried to add "2" to the "if/echo" statement in various ways, but I always get some kind of error. How do I rewrite this statement to include an activation value of either "1" or "2"?

if ($activated == "1") {
echo ("You will be redirected to your appropriate section in 3 seconds.")

What is the correct way to write both lines of code?

*Wasn't sure if I should post this in the "Database" or the "PHP" section.

oceanwave

6:54 pm on Oct 5, 2007 (gmt 0)

10+ Year Member



Decided to do it differently - setting page link inside database so I don't need different activation numbers.