Jump to content

Can't get this code to work!


Drakken_

Recommended Posts

So I have this code that checks if a user if banned on the website or not (Through a MySQL database) However, this code that DID IN FACT work, is not working anymore. Whenever I try to check if a player is banned, that I know for sure are banned, they show up as not banned. I have no clue what happened to change the way it works, but all I know is that is doesn't work anymore. Here is what I have:
 
config.inc.php:
 

 

    <?php
    session_start();
    error_reporting(1);
    mysql_connect("localhost", "root", "<hidden>")or die("DB connection failed: " . mysql_error());
    mysql_select_db("bridge")or die("DB selection failed");
    
    ?>
 

 

 
 
index.php:
 

 

    <?php
    require_once("config.inc.php");
    error_reporting(0);
    $action = $_GET["a"];
    
    if ($action=="checkban"){
     $player = $_GET["p"];
     $username = mysql_real_escape_string($_GET["p"]);
     $result = mysql_query("SELECT * FROM player_bans WHERE UPPER(player_bans) = UPPER('$username') LIMIT 1");
     $row = mysql_fetch_array($result);
     if ($row["banned"] == 1){
     echo("success");
     //send(array($row));
     } else {
     echo("failiure<br />");
     echo($row["banned"]);
     }
    }
    
    ?>
 

 

 
Here is the player_bans table as well:
 
4Dw3i6e.png
Link to comment
https://forums.phpfreaks.com/topic/276038-cant-get-this-code-to-work/
Share on other sites

error_reporting(1) is a bit weak, try -1 instead.

 

Why have you turned it off in index.php?

 

Where is $username defined.

 

Did you have register_globals ON and now it is OFF?

 

 

Fixed the error reporting, although doesn't fix the problem.

 

What did I turn off in index.php?

 

Username is defined on the 8th line of index.php 

 

$username = mysql_real_escape_string($_GET["p"]);
 

 

 

What is register_globals? That isn't present in the code..

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.