Jump to content

Query Problem


Tom10
Go to solution Solved by cyberRobot,

Recommended Posts

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: 

0de933fb29ee5c46e51170a1a4b935cf.png

It doesn't matter if it's 0 or 1 it still includes the access denied page.

Edited by Tom10
Link to comment
Share on other sites

 

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.