Jump to content

serious problem with prepared statement


jimfog

Recommended Posts

I am facing a very weird situation with a prepared statement....if I run the sql statement in the editor(NEtbeans IDE console I get back a row.

 

The same statement though as a prepared statement returns 0 row...here is the code:

 if($stmt = $connection->prepare("SELECT name FROM users WHERE registr_hash=(?) AND email=(?)"))          {   $stmt->bind_param('ss',$hash,$email);//αυτο το έχω αλλάξει για testing..κανονικα ειναι siisii         $stmt->execute();         $stmt->store_result();           var_dump($stmt->num_rows);return;//this here returns 0 while it should return 1           if($stmt->errno!==0)                     {          error_log("error message for check_member_status()-execution  failed:".$stmt->error."for buser:".$email.",time of error:".date('d F Y h i')." n", 3,"../Administrator/error_log.log");         mail_error($email);return  false;                     }                                        if($stmt->num_rows>0){        // We have a match                $result=activate_account($connection,$email,$hash);                $stmt->fetch();                $_SESSION['valid_user'] = $email;                if($result==true)                    {                                         if($usertype==='buz_user')                     {header("Location: buz_member.php?verified=true");}                     else                     {}                    }//$status='O κωδικός σου επιβεβαιώθηκε';                 //go to adminmember page                                        }else{        // No match -> invalid url or account has already been activated.                $status='<div class="statusmsg">wrong URL or you have already activated your account.</div>';              }     }     else     {        error_log("error message for check_member_status()-prepared  failed:".$connection->error."for buser:".$email.",time of error:".date('d F Y h i')." n", 3,"../Administrator/error_log.log");        mail_error($email);return  false;                }

What can be wrong? I have checked the syntax of the prepared statement above myriad times.

Link to comment
Share on other sites

Why are there parentheses around the placeholders? It probably isn't the cause of the problem, but it's something unnecessary.

 

Have you checked that $hash and $email have the correct values?

Link to comment
Share on other sites

Why are there parentheses around the placeholders? It probably isn't the cause of the problem, but it's something unnecessary.

 

Have you checked that $hash and $email have the correct values?

You are right about the parentheses..they are not needed.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...