Really strange

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Igguana
Forum Commoner
Posts: 36
Joined: Tue Mar 11, 2003 1:08 pm

Really strange

Post by Igguana »

Why this stupid conditional is always giving me the first value ("SI"), even though the condition is not true?
Any hipotesis?

Code: Select all

<?php
<?
			if ($row['Agua']=1){
			echo "SI";
			}
			else{
			echo "NO";
			}
                                                ?>
?>
CyberSpatium
Forum Newbie
Posts: 21
Joined: Thu Mar 20, 2003 12:23 pm
Contact:

Post by CyberSpatium »

add an extra equal sign to make it equal to..

like this:

if ($row['Agua'] == 1){

Cyber
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

CyberSpatium wrote:add an extra equal sign to make it equal to..
Exactly, the way you had it before meant it was setting $row['Agua'] equal to 1 not testing to see if it was equal to 1 that means that you always got the first result.

For more information:
http://www.php.net/manual/en/language.o ... arison.php

Mac
Post Reply