Tom10 Posted February 20, 2015 Share Posted February 20, 2015 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. Link to comment https://forums.phpfreaks.com/topic/294756-query-problem/ Share on other sites More sharing options...
cyberRobot Posted February 20, 2015 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"; Link to comment https://forums.phpfreaks.com/topic/294756-query-problem/#findComment-1506283 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 Link to comment https://forums.phpfreaks.com/topic/294756-query-problem/#findComment-1506284 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! Link to comment https://forums.phpfreaks.com/topic/294756-query-problem/#findComment-1506285 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.