Register and Login
Posted: Thu Jun 21, 2012 2:36 pm
Hi I have been following your tutorials for a while now and I am stuck with this one!
I keep getting the error message: Warning: mysql_result() expects parameter 1 to be resource, boolean given in /customers/2/b/e/warrenamphlett.co.uk/httpd.www/core/inc/user.inc.php on line 9
I have checked everything that I know to check, but now I'm stumped because I followed your ever step to a T...
here is my code:
I keep getting the error message: Warning: mysql_result() expects parameter 1 to be resource, boolean given in /customers/2/b/e/warrenamphlett.co.uk/httpd.www/core/inc/user.inc.php on line 9
I have checked everything that I know to check, but now I'm stumped because I followed your ever step to a T...
here is my code:
<?php // Check if the given username exists in the database. function user_exists($user){ $user = mysql_real_escape_string($user); $total = mysql_query("SELECT COUNT('user_id') FROM 'users' WHERE 'user_name' = '{$user}'"); return (mysql_result($total, 0) == '1') ? true : false; } // Checks if the given username and password combination is valid. 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; } // Adds a user to the database 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}')"); } ?>Please please help...