-1

i have to trouble trying to debug this code and i know it´s something on line 26 and i have tried different methods to solve it like changing it to mysql and defining db

<?php
session_start();

include('connection.php');

if(isset($_POST['Login']))
{
    include ('/ClassLogin.php');  
    $login = new Login();
    if
        ($login->isLoggedIn())
        header('location: indeks.html');
    else 
        $login->showErros ();
}
$Token = $_SESSION['token'] = md5(uniqid(mt_rand(),TRUE));

$username = $_POST["username"];
$password = $_POST["password"];

$sql = "SELECT id FROM $tbl WHERE username = '$username' and password = '$password'";
class db extends mysqli 
{


  function __construct($localhost, $username, $password, $pokemon7_users, $port=80){
   mysqli::__construct($localhost, $username, $password, $pokemon7_users, $port);
    } 
    $result = mysqli($db, $sql, $link);

if (!result)
{
    printf("Error: ", mysql_error($link));
}
else
{
    Echo "Congratulations you are now logged in";
}
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345

4 Answers4

2

You forgot the dollar :)

!result -> !$result

Also don't mix between mysqli and mysql. mysql_ functions are deprecated and you should not use them anymore.

It would be better and more readable to define classes in separate files.

Mihai Matei
  • 24,166
  • 5
  • 32
  • 50
0

This

if (!result) {

must be

if (!$result) {

Your missing the Dollar sign

Busster
  • 1
  • 1
0

replace if (!result) by if (!$result)

Pradyut Manna
  • 588
  • 1
  • 3
  • 12
0

I checked your code and you did not closed your class:

class db extends mysqli 
{
  function __construct($localhost, $username, $password, $pokemon7_users, $port=80)
  {
    mysqli::__construct($localhost, $username, $password, $pokemon7_users, $port);
  }
} 

Also there are a typos:

if (!result) to if (!$result)

Also i can not find any data which you pass for database info for example $localhost

Majid Abbasi
  • 1,531
  • 3
  • 12
  • 22