adamjones Posted October 11, 2008 Share Posted October 11, 2008 Ok. I have wrote this code; <?php $host="localhost"; $username="wowdream_domaine"; $password="PASS"; $db_name="wowdream_domaine"; $tbl_name="maintenance"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); ?> <?php while($rows=mysql_fetch_array($result)){ ?> <? if ($rows['check'] = yes) { echo "Turn maintenance mode off"; } else echo "Turn maintenance mode on"; } ?> The problem is, it always echo's "Turn maintenance mode off", even if the value in my table is set to something else. I'm guessing I have an error in my code, right? Cheers. Quote Link to comment Share on other sites More sharing options...
AndyB Posted October 11, 2008 Share Posted October 11, 2008 if ($rows['check'] = yes) { should be if ($rows['check'] == yes) { Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 11, 2008 Share Posted October 11, 2008 EDIT: Beaten to it This line is the issue: if ($rows['check'] = yes) { Use the comparion operator (==) not the assignment operator (=) Also I advise you to avoid using short tags (<? ?> or <?= ?>). Using short tags makes your code less portable as not all PHP installations have short tags enabled. Quote Link to comment Share on other sites More sharing options...
adamjones Posted October 11, 2008 Author Share Posted October 11, 2008 Ok. Thanks guys, its working now. This site is like a turn site on/off right? Like, yes or no? Like no means its being worked on and yes means site is active and up. Its very cool. I like it. Yep- that's right. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.