Jump to content


Photo

Can't get this code to work!

php phpmyadmin users

  • Please log in to reply
5 replies to this topic

#1 Drakken_

Drakken_

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 22 March 2013 - 08:04 PM

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


#2 Barand

Barand

    Sen . ( ile || sei )

  • Gurus
  • 13,885 posts
  • LocationCheshire, UK

Posted 22 March 2013 - 08:19 PM

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?


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts
|baaSelect| generate js and php code for dynamic linked dropdowns

 


#3 Drakken_

Drakken_

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 22 March 2013 - 08:25 PM

<removed>


Edited by Drakken_, 22 March 2013 - 08:38 PM.


#4 Drakken_

Drakken_

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 22 March 2013 - 08:26 PM

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



#5 PaulRyan

PaulRyan

    Hello World

  • Members
  • PipPipPip
  • 873 posts
  • LocationUK
  • Age:22

Posted 23 March 2013 - 05:13 AM

Shouldn't "UPPER(player_bans)" in fact be "UPPER(name)"?


Edited by PaulRyan, 23 March 2013 - 05:13 AM.

My Internet Home - Dumping ground for new ideas/tips/tricks and general grievances of developing.

 

Firefox 17 - PHP 5.4 - MySQL 5 - Win7 [64-bit]

Rule for asking for help: If you don't show that you've tried to accomplish something, you don't deserve help.


#6 Barand

Barand

    Sen . ( ile || sei )

  • Gurus
  • 13,885 posts
  • LocationCheshire, UK

Posted 23 March 2013 - 05:46 AM

What did I turn off in index.php?

 

You turned off error reporting with

 

error_reporting(0);

 

http://php.net/manua...ity.globals.php


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts
|baaSelect| generate js and php code for dynamic linked dropdowns

 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com