942,956 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 408
  • PHP RSS
Jul 7th, 2010
0

PHP IF statement seems to be redefining a variable

Expand Post »
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...

PHP Syntax (Toggle Plain Text)
  1. $query1="SELECT * FROM $clean_title WHERE lname='$last_name' AND fname='$first_name' AND first='yes'";
  2. $result1=mysql_query($query1) or die(mysql_error());
  3. if (mysql_num_rows($result1) > 0)
  4. {
  5. if ($new="yes")
  6. {
  7. echo'
  8. This character has already been entered as new
  9. ';
  10. }
  11. else
  12. {
  13. echo'
  14. Character can be entered into database
  15. ';
  16. }
  17. }
  18. else
  19. {
  20. echo'
  21. Character can be entered into database
  22. ';
  23. }
  24.  
  25. mysql_close();

Pleas help. I know I just must be doing something wrong someweher but I can't see it.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
surfgrommett is offline Offline
14 posts
since May 2010
Jul 7th, 2010
0
Re: PHP IF statement seems to be redefining a variable
Try
PHP Syntax (Toggle Plain Text)
  1. $new=="yes"
Sponsor
Featured Poster
Reputation Points: 1036
Solved Threads: 933
Sarcastic Poster
ardav is offline Offline
6,613 posts
since Oct 2006
Jul 7th, 2010
0
Re: PHP IF statement seems to be redefining a variable
Click to Expand / Collapse  Quote originally posted by ardav ...
Try
PHP Syntax (Toggle Plain Text)
  1. $new=="yes"


excellent! thank you! i KNEW it had to be something small i was missing!
Reputation Points: 10
Solved Threads: 1
Newbie Poster
surfgrommett is offline Offline
14 posts
since May 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: htaccess rewrite issue - folder redirect to file
Next Thread in PHP Forum Timeline: PHP Login box





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC