adamjones Posted October 11, 2008 Share Posted October 11, 2008 I wish I knew PHP, off by heart! Ok. Earlier, a few guys helped to fix this code (cheers); <?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 "<a href='turnmaintenanceoff.php'>Turn maintenance mode off</a>"; } else echo "<a href='turnmaintenanceon.php'>Turn maintenance mode on</a>"; } ?> Now, when going to 'turnmaintenanceoff.php', It just echos my error. This is the 'turnmaintenanceoff.php' 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="UPDATE $tbl_name SET check='yes' WHERE check='no'"; $result=mysql_query($sql); if($result){ echo "DONE"; else { echo "ERROR"; } ?> Sorry about asking for help, again! Link to comment https://forums.phpfreaks.com/topic/128003-another-error/ Share on other sites More sharing options...
AndyB Posted October 11, 2008 Share Posted October 11, 2008 Let's fix the first one properly: <?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); while($rows=mysql_fetch_array($result)){ if ($rows['check'] == yes) { echo "<a href='turnmaintenanceoff.php'>Turn maintenance mode off</a>"; } else { echo "<a href='turnmaintenanceon.php'>Turn maintenance mode on</a>"; } } ?> Note how proper indentation makes it obvious that you were a closing brace short in your code. Link to comment https://forums.phpfreaks.com/topic/128003-another-error/#findComment-662822 Share on other sites More sharing options...
adamjones Posted October 11, 2008 Author Share Posted October 11, 2008 Oh, Ok. I see. Thanks. So now I have; <?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); while($rows=mysql_fetch_array($result)){ if ($rows['check'] == yes) { echo "<a href='turnmaintenanceoff.php'>Turn maintenance mode off</a>"; } else { echo "<a href='turnmaintenanceon.php'>Turn maintenance mode on</a>"; } } ?> and 'turnmaintenanceon.php' is; <?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="UPDATE $tbl_name SET check='yes' WHERE check='no'"; $result=mysql_query($sql); if($result){ echo "DONE"; } else { echo "ERROR"; } ?> I just can't work out what's wrong. Link to comment https://forums.phpfreaks.com/topic/128003-another-error/#findComment-662826 Share on other sites More sharing options...
smithmr8 Posted October 11, 2008 Share Posted October 11, 2008 Try this. It sometime's solves problems for me. <?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="UPDATE `$tbl_name` SET `check`='yes' WHERE `check`='no'"; $result=mysql_query($sql); if($result){ echo "DONE"; } else { echo "ERROR"; } ?> Link to comment https://forums.phpfreaks.com/topic/128003-another-error/#findComment-662829 Share on other sites More sharing options...
adamjones Posted October 11, 2008 Author Share Posted October 11, 2008 Cheers! All working now. Link to comment https://forums.phpfreaks.com/topic/128003-another-error/#findComment-662834 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.