V
V
valitskiydmitriy2015-11-18 15:25:46
PHP
valitskiydmitriy, 2015-11-18 15:25:46

Where can be MYSQL and PHP error?

There is this line:

$query =mysql_query("SELECT * FROM usertbl WHERE username='".$username."' AND password='".$password."'");

Authorization does not work, query was empty error Tables exist, everything seems to be written correctly, but does not work

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Cat Anton, 2015-11-18
@valitskiydmitriy

mysql_query() returns a handle to the query result (resource), or FALSE on error .

php.net/manual/ru/function.mysql-query.php
The word PASSWORD is reserved in MySQL. Therefore, you need to wrap the column name in backticks.
$username = htmlspecialchars($_POST['username']);
$password = htmlspecialchars($_POST['password']);
$query = mysql_query("SELECT * FROM usertbl WHERE username='".$username."' AND `password`='".$password."'");
if (!$query) {
    die('Ошибка: ' . mysql_error());
}
$numrows = mysql_num_rows($query);

V
Viktor, 2015-11-18
@master2016

Run a bare query in some mysql IDE - in the same phpMyAdmin, for example. If the request goes through normally, then the error is somewhere in PHP.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question