Page 1 of 1

Easy for someone (not me) question

Posted: Thu Jan 01, 2009 8:51 am
by SoapDude
Here's the code I'm having trouble with. I have a line in my MySQL database named Need_Help. It is set to return a 1 or a 0:

Need_Help tinyint(1) No 0

My problem is that the code is returning 'Need Help' regardless of the value of the Need_Help line in my database. Thanks in advance and Happy New Year!

if (mysql_num_rows($result) > 0) {
while($row = mysql_fetch_object($result)) {
if($row->Need_Help = 1) {
echo 'Need Help';
}
echo '<b><a href="' . $row->Web_Address . '">' . $row->Company_Name . '</a></b>

<br /> ';
echo $row->City . ', &nbsp ' . $row->State . ', &nbsp ' . $row->Country . ' &nbsp

&nbsp ' ;
echo $row->Comment ;
echo '<br /><br /> ';
}

}

Re: Easy for someone (not me) question

Posted: Thu Jan 01, 2009 10:30 am
by Mark Baker

Code: Select all

 
if($row->Need_Help == 1) {
 

Re: Easy for someone (not me) question

Posted: Thu Jan 01, 2009 11:00 am
by SoapDude
Haha 3 cheers!!! You're amazing! It works! Thanks and Happy New Year!

Re: Easy for someone (not me) question

Posted: Thu Jan 01, 2009 1:18 pm
by watson516
Just to clear it up, a single = is an assignment character meaning that in your IF statement, you were assigning $row->Need_Help to equal 1 so it always returned true.

Re: Easy for someone (not me) question

Posted: Thu Jan 01, 2009 2:11 pm
by SoapDude
Got it now... Thanks much!