Tom10 Posted February 20, 2015 Share Posted February 20, 2015 (edited) Hi, i am sending a query to my database, to check if my website is under maintainance, it's ment to display an access denied page if maintainance in the table is equal to 1 but it's not working properly. Here is the code: <?php error_reporting(E_ALL | E_NOTICE); require 'connect.php'; session_start(); $pageMaintain = "SELECT maintainance FROM config"; $result = mysqli_query($con, $pageMaintain); if(mysqli_num_rows($result) == 1) { include 'accessdenied.php'; die(); } else { } ?> And a picture of the table: It doesn't matter if it's 0 or 1 it still includes the access denied page. Edited February 20, 2015 by Tom10 Quote Link to comment Share on other sites More sharing options...
Solution cyberRobot Posted February 20, 2015 Solution Share Posted February 20, 2015 Have you tried adding a WHERE clause? Basically, you only want the query to return a row if the maintenance column is set to 1. Maybe something like this: $pageMaintain = "SELECT maintainance FROM config WHERE maintainance=1"; 1 Quote Link to comment Share on other sites More sharing options...
Tom10 Posted February 20, 2015 Author Share Posted February 20, 2015 Have you tried adding a WHERE clause? Basically, you only want the query to return a row if the maintenance column is set to 1. Maybe something like this: $pageMaintain = "SELECT maintainance FROM config WHERE maintainance=1"; Thank you!, It worked Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted February 20, 2015 Share Posted February 20, 2015 Thank you!, It worked No problem, glad to help! 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.