954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP IF statement seems to be redefining a variable

Hi guys. First I have spent awhiel trying to find an answer for this online and haven't been able to. I have defined a variable ($new) in the beginning of my page. to test that is IS defined right i echo'd it...im using nested if statements to check thing. in the second if statement for some reason the variable is redefined to 'yes'. why is this? all the code isnt doine..im testing as i go useing text just to see that things are being evaluiated right..here is the code...

$query1="SELECT * FROM $clean_title WHERE lname='$last_name' AND fname='$first_name' AND first='yes'";
$result1=mysql_query($query1) or die(mysql_error());
if (mysql_num_rows($result1) > 0)
        {
        if ($new="yes")
                {
                echo'
                This character has already been entered as new
                ';
                }
                else
                {
                echo'
                Character can be entered into database
                ';
                }
        } 
        else
        {
        echo'
        Character can be entered into database
        ';
        }

mysql_close();


Pleas help. I know I just must be doing something wrong someweher but I can't see it.

surfgrommett
Newbie Poster
14 posts since May 2010
Reputation Points: 10
Solved Threads: 1
 

Try

$new=="yes"
diafol
Rhod Gilbert Fan (ardav)
Moderator
7,765 posts since Oct 2006
Reputation Points: 1,168
Solved Threads: 1,075
 

Try

$new=="yes"

excellent! thank you! i KNEW it had to be something small i was missing!

surfgrommett
Newbie Poster
14 posts since May 2010
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You