I am new to PHP and I have been following a tutorial on how to build a login and registration form. Can someone help me figure out what is wrong with this line of code.
function user_active($username) {
$username = sanitize($username);
return (mysql_result(mysql_query(“SELECT * FROM user WHERE username =’$username’ AND active = 1”), 0) == 1) ? true : false;
}
This is the error I am getting: ( I am using dreamweaver)
( ! ) SCREAM: Error suppression ignored for
( ! ) Warning: mysql_result(): Unable to jump to row 0 on MySQL result index 15 in C:\wamp\www\Template\core\functions\users.php on line 31
Call Stack
It is returning an error in my registration form (properly). I just wasn’t sure if my code was broken. I was reading something about the PDO and mysqli, but I wasn’t sure how I could implement that change and still keep with this tutorial I am following. Any suggestions?
If you execute the query manually does it return any results? You are executing mysql_result without knowing if there are any results. If the query returns zero the mysql_result function will always fail.
thanks it seems to be working fine I just have it showing errors so it shows that there is an error when there isn’t. Or at least that is what I am assuming. Thanks for the tutorial i will check it out.