tomfmason
07-08-2006, 10:27 AM
I have am trying(unsuccessfully) to create a login script. I get the following error
heres the code:
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in test_login.php on line 13
<?php
include ('includes/db.php');
array_pop($_POST);
if ( get_magic_quotes_gpc() ) {
$_POST= array_map('stripslashes', $_POST);
}
$username= mysql_real_escape_string(trim($_POST['username']));
$password= mysql_real_escape_string(trim($_POST['password']));
$sql= sprintf("SELECT COUNT(*) AS login_match FROM `users` WHERE `username` = '%s' AND `user_password`= '%s'", $username, $password);
$res= mysql_query($sql);
$login_match= mysql_result($res, 0, 'login_match');
if ( $login_match == 1 ) {
echo "This test worked";
} else {
echo "This test did not work";
// not logged in
}
?>
line 13:
$login_match= mysql_result($res, 0, 'login_match');
I am wondering if anyone can suggest as to why this is happening?
heres the code:
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in test_login.php on line 13
<?php
include ('includes/db.php');
array_pop($_POST);
if ( get_magic_quotes_gpc() ) {
$_POST= array_map('stripslashes', $_POST);
}
$username= mysql_real_escape_string(trim($_POST['username']));
$password= mysql_real_escape_string(trim($_POST['password']));
$sql= sprintf("SELECT COUNT(*) AS login_match FROM `users` WHERE `username` = '%s' AND `user_password`= '%s'", $username, $password);
$res= mysql_query($sql);
$login_match= mysql_result($res, 0, 'login_match');
if ( $login_match == 1 ) {
echo "This test worked";
} else {
echo "This test did not work";
// not logged in
}
?>
line 13:
$login_match= mysql_result($res, 0, 'login_match');
I am wondering if anyone can suggest as to why this is happening?