Easy for someone (not me) question

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
SoapDude
Forum Newbie
Posts: 6
Joined: Thu Jan 01, 2009 8:45 am

Easy for someone (not me) question

Post 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 /> ';
}

}
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Easy for someone (not me) question

Post by Mark Baker »

Code: Select all

 
if($row->Need_Help == 1) {
 
SoapDude
Forum Newbie
Posts: 6
Joined: Thu Jan 01, 2009 8:45 am

Re: Easy for someone (not me) question

Post by SoapDude »

Haha 3 cheers!!! You're amazing! It works! Thanks and Happy New Year!
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: Easy for someone (not me) question

Post 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.
SoapDude
Forum Newbie
Posts: 6
Joined: Thu Jan 01, 2009 8:45 am

Re: Easy for someone (not me) question

Post by SoapDude »

Got it now... Thanks much!
Post Reply