0

Hi, i am getting this error for an email activation function. can someone help me removing this error message and make it work?

Error:

Warning: mysql_result() expects parameter 1 to be resource, boolean given in /home/prevpxmj/public_html/core/functions/users.php on line 6

Code:

<?php
function activate($email, $email_code){
    $email = mysql_real_escape_string($email);
    $email_code = mysql_real_escape_string($email_code);

    if (mysql_result(mysql_query("SELECT COUNT (`user_id`) FROM `users` WHERE `email` = '$email' AND `email_code` = '$email_code' AND `active` = 0"), 0)==1) {
        // query to upadate user activa status
        mysql_query("UPDATE `users` SET `activate` = 1 WHERE `email` = '$email'");
        return true;
    } else {
        return false;    
    }
}
?>

Edited by eoop.org

4
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by tyson567
0

It means that your select query isn't returning any results, probably due to some kind of error. Maybe you could try to output a mysql_error()? Just put the following statement before the return functions: echo mysql_error(); and see what it does.

0
  • Try the following it may work -
    in line 6:
    1) remove the word COUNT
    2) change

    (userid) to userid

without brackets

3) change

0" to `0`"

Edited by tyson567: minor

0
if (mysql_result(mysql_query("SELECT COUNT (`user_id`) FROM `users` WHERE `email` = '$email' AND `email_code` = '$email_code' AND `active` = 0"), 0)==1) {

Error in this line....
mysql_result reference read this.....Click Here
Return type is String and u are compairing it with 1.....

Instead of this use....."mysql_num_rows"
For Reference read this

0
if (mysql_result(mysql_query("SELECT COUNT (`userid`) FROM `users` WHERE `email` = '$email', `email_code` = '$email_code' AND `active` = 0"), 0)==1) {

Try comma in place of the First 'AND'

Edited by tyson567: minor

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.