Help: mysql_fetch_row () expects parameter 1 to be resource

0

I do not understand why I have the following error:

[18-Jun-2018 04:03:56 UTC] PHP Warning:  mysql_fetch_row() expects parameter 1 to be resource, boolean given in /home/minetani/test.minetanium.us/cuenta/registro/index.php on line 29

I've done everything right, or I think so .. Here I leave my index.php

<?php
session_start();
function ambil_ip() {
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_REAL_IP', 'REMOTE_ADDR', 'HTTP_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED') as $key) {
if (array_key_exists($key, $_SERVER) === true) {
  foreach (explode(',', $_SERVER[$key]) as $ip) {
    if (filter_var($ip, FILTER_VALIDATE_IP) !== false) {
      return $ip;
    }
  }
}
}
}
include('../logeo/auth.php');
session_start();

#-----------------------------------------------------------------------------#

$username = $_POST['username'];
$username = mysql_real_escape_string($username);
$checkuser1 = mysql_query("SELECT * FROM USERS WHERE username = '$username'");
$checkuser2 = mysql_num_rows($checkuser1);

#-----------------------------------------------------------------------------#

$key = $_POST['key'];
$key = mysql_real_escape_string($key);
$checkkey1 = mysql_query("SELECT status FROM KEYS WHERE key = '$key'");
$checkkey2 = mysql_fetch_row($checkkey1);

#-----------------------------------------------------------------------------#

$password = $_POST['password'];
$password = md5(md5(md5($password)));
$checkpass1 = mysql_query("SELECT password FROM USERS WHERE username = '$username'");
$checkpass2 = mysql_fetch_row($checkpass1);

$ip = ambil_ip();

if ($checkuser2 == 0) {
    if ($checkkey4 == 1) {
        $_SESSION['username'] = $username;
        $k = mysql_query("UPDATE 'USERS' SET 'ip'='$ip' WHERE username='$username'");
        header('location:../registro.php?success=1');
    }
    else {
        echo $checkkey2;
        header('location:../registro.php?error=2');
    }
}
else {
    echo $checkkey2;
    header('location:../registro.php?error=1');
}

?>

Could you help me correct it? Thank you very much

I get the following error when doing echo of mysql.error ();

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'KEYS WHERE key = '123'' at line 1
    
asked by Michael Santana 18.06.2018 в 06:14
source

0 answers