Ahh yes, that got me past that, now getting:
Warning: mysql_result() expects parameter 1 to be resource, boolean given in /home/content/64/7274864/html/musicspot2/core/inc/user.inc.php on line 9
Fatal error: Call to undefined function htmlentites() in /home/content/64/7274864/html/musicspot2/core/inc/user.inc.php on line 24
<?php
// Checks 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 `users2` WHERE `user_name` = '{$user}'");
return (mysql_result($total, 0) == '1') ? true : false;
}
// Checks is 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 `users2` 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($user);
$pass = sha1($pass);
mysql_query("INSERT INTO `users2` (`user_name`, `user_password`) VALUES ('{$user}', '{$pass}')");
}
?>
users2 is the correct name for my DB. Thank you for the super fast reply on the last post!