Page 1 of 1

Really strange

Posted: Thu Mar 20, 2003 11:19 am
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";
			}
                                                ?>
?>

Posted: Thu Mar 20, 2003 12:23 pm
by CyberSpatium
add an extra equal sign to make it equal to..

like this:

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

Cyber

Posted: Fri Mar 21, 2003 2:12 am
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