# can't figure out the error

**URL:** <https://www.phphelp.com/t/cant-figure-out-the-error/18910>\
**Category:** MySQL database\
**Created:** [November 14, 2012, 4:56am UTC](https://www.phphelp.com/t/cant-figure-out-the-error/18910 "2012-11-14T04:56:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimLCooley](https://www.phphelp.com/user_avatar/www.phphelp.com/timlcooley/32/817_2.png) [@TimLCooley](https://www.phphelp.com/u/TimLCooley)\
**Post date:** [November 14, 2012, 4:56am UTC](https://www.phphelp.com/t/cant-figure-out-the-error/18910/1 "2012-11-14T04:56:01Z")

</div>

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

# Time Memory Function Location

1 0.0020 261736 {main}( ) …\register.php:0  
2 0.0250 295280 user\_exists( ) …\register.php:30  
3 0.0256 298680 mysql\_result ( ) …\users.php:31

I am clearly not decent enough to trace the pathing error so any suggestions would be awesome.

---

<div class="post-metadata">

**Author:** ![m11](https://www.phphelp.com/letter_avatar_proxy/v4/letter/m/85f322/32.png) [@m11](https://www.phphelp.com/u/m11)\
**Post date:** [November 14, 2012, 5:06am UTC](https://www.phphelp.com/t/cant-figure-out-the-error/18910/2 "2012-11-14T05:06:47Z")

</div>

Are you starting from scratch? If so, I would recommend learning to use either PDO or mysqli

As far as your error goes, I’m guessing that mysql\_query is either returning an error or no results.

---

<div class="post-metadata">

**Author:** ![TimLCooley](https://www.phphelp.com/user_avatar/www.phphelp.com/timlcooley/32/817_2.png) [@TimLCooley](https://www.phphelp.com/u/TimLCooley)\
**Post date:** [November 14, 2012, 5:35am UTC](https://www.phphelp.com/t/cant-figure-out-the-error/18910/3 "2012-11-14T05:35:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![m11](https://www.phphelp.com/letter_avatar_proxy/v4/letter/m/85f322/32.png) [@m11](https://www.phphelp.com/u/m11)\
**Post date:** [November 14, 2012, 7:25am UTC](https://www.phphelp.com/t/cant-figure-out-the-error/18910/4 "2012-11-14T07:25:46Z")

</div>

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.

Here is a good tutorial to learn PDO

> **[Why You Should Be Using PHP's PDO for Database Access](https://code.tutsplus.com/tutorials/why-you-should-be-using-phps-pdo-for-database-access--net-12059)**
>
> Many PHP programmers learned how to access databases by using either the MySQL or MySQLi extensions. As of PHP 5.1, there's a better way. PHP Data Objects (PDO) provide methods for prepared...

---

<div class="post-metadata">

**Author:** ![TimLCooley](https://www.phphelp.com/user_avatar/www.phphelp.com/timlcooley/32/817_2.png) [@TimLCooley](https://www.phphelp.com/u/TimLCooley)\
**Post date:** [November 14, 2012, 7:55am UTC](https://www.phphelp.com/t/cant-figure-out-the-error/18910/5 "2012-11-14T07:55:33Z")

</div>

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.
