I am getting the following errors and I cannot figure it out:
Warning: mysql_result() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/login/core/inc/user.inc.php on line 11
Here is the code:
<?php
function user_exists($user){
$user = mysql_real_escape_string($user);
$total = mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'user_name' = '{$user}'");
//why is this not allowing the script to register the user???
return (mysql_result($total, 0) == '1') ? true : false;
}
function valid_credentials($user, $pass){
$user = mysql_real_escape_string($user);
$pass = sha1($pass);
$total = mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'user_name' = '{$user}' AND 'user_password' = '{$pass}'");
return (mysql_result($total, 0) == '1') ? true : false;
}
function add_user($user, $pass){
$user = mysql_real_escape_string(htmlentities($user));
$pass = sha1($pass);
mysql_query("INSERT INTO 'users' ('user_name', 'user_password') VALUES ('{$user}', '{$pass}')");
}
?>
I am new to PHP, it's only been a few weeks. I followed the video (i thought) to a "T" but i guess not... can anyone lend a hand and tell me what I did wrong? Thanks...
Last edited by jacek on Fri Apr 06, 2012 11:41 pm, edited 1 time in total.
Reason:code tags...
Yep that is it If you use ' it tells MySQL that the thing between them is not a table name, to tell it that is is a table of column name you need to use backticks `