-1

I'm very new to both PHP and MySQL.

I have only begun to learn them to run a game server.

The problem I have run into is descriped in apache error log as:

[Mon Sep 04 01:00:16.928467 2017] [:error] [pid 3656:tid 784] [client 127.0.0.1:49401] PHP Notice: Undefined variable: db in C:\Program Files\VertrigoServ\www\sw_game_login.php on line 24

[Mon Sep 04 01:00:16.928467 2017] [:error] [pid 3656:tid 784] [client 127.0.0.1:49401] PHP Stack trace:

[Mon Sep 04 01:00:16.928467 2017] [:error] [pid 3656:tid 784] [client 127.0.0.1:49401] PHP 1. {main}() C:\Program Files\VertrigoServ\www\sw_game_login.php:0

[Mon Sep 04 01:00:16.928467 2017] [:error] [pid 3656:tid 784] [client 127.0.0.1:49401] PHP Fatal error: Call to a member function fetch_row() on null in C:\Program Files\VertrigoServ\www\sw_game_login.php on line 24

[Mon Sep 04 01:00:16.928467 2017] [:error] [pid 3656:tid 784] [client 127.0.0.1:49401] PHP Stack trace:

[Mon Sep 04 01:00:16.928467 2017] [:error] [pid 3656:tid 784] [client 127.0.0.1:49401] PHP 1. {main}() C:\Program Files\VertrigoServ\www\sw_game_login.php:0

line 24 of sw_game_login.php looks like the following:

if(list($id)=$db->fetch_row($db->query("SELECT ID FROM accounts WHERE ACCOUNT_NAME='$account' AND ACCOUNT_PASSWORD='$pass'"))){

The error I receive from my game client says that incorrect account or password, I know this is not the case I have tried several and checked several times. Thus leading me to believe that maybe the request is not being sent through properly.

Thanks in advance to any help!

Community
  • 1
  • 1

1 Answers1

1

According to your error log, your db variable is undefined. Add this to the top of your sw_game_login.php script.

if (!isset($db))
    $db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
sf_admin
  • 577
  • 4
  • 11
  • Maybe we should teach about input validation/sanitization while you are at it ? :) – MrK Sep 03 '17 at 16:25