Hey, DaniWeb friends!
I've a problem with my login.php: When an error occurred, the
mysql_error();
doesn't appear the error. Tested the
mysql_errno()
also, it appears as 0, saying it doesn't have any errors. Take a look at the script:
<?php
$username = $_POST['username'];
$pass = $_POST['password'];
require "conf/connection.php";
require "layout/nav.php";
$result = mysql_query("SELECT * FROM users WHERE uname = '$username' AND password = '$pass'");
$total = mysql_num_rows($result);
$r = mysql_fetch_array($result);
if ($total == 0){
echo 'An error occurred: ' . mysql_error() . 'The error code: ' . mysql_errno();
} else {
session_start();
$_SESSION['id'] = $r['id'];
$_SESSION['uname'] = $r['uname'];
$_SESSION['password'] = $r['password'];
header("Location: logged.php");
}
?>