This code snippet, when called, displays a news alert on a page. However, when the News Alert is turned off (click here to turn off), the database field doesn't change, and thus, the code doesn't work. function news_alert($m_alert_banner, $m_id){ if($m_alert_banner == "Yes") { $news_alert = mysql_query("SELECT * FROM `TABLE`"); while ($c = mysql_fetch_array($news_alert)) { echo ("<center><div class=\"message loginerror\">$c[news_alert]<br/> <a href=\"?act=off\">Turn Off News Alert</a></center> <br/><center>"); } if ($_GET['act'] == "off") { echo("<div class=\"message success\">You've turned off the News Alert. $m_id</div>"); mysql_query("UPDATE `TABLE` SET `alert_banner` = 'No' WHERE `id` = '$m_id'"); } } return $news_alert_banner; } PHP: That is the function, and here is how I'm calling it. news_alert("Yes", "$m_id"); PHP:
You only need to put quotes around a string, not the variable. Meaning remove the quote from the second parameter since you're passing it as a variable and not a string.