mysql data being inserted twice via php

Posted by Jascha on Stack Overflow See other posts from Stack Overflow or by Jascha
Published on 2010-05-17T22:03:18Z Indexed on 2010/05/17 22:10 UTC
Read the original article Hit count: 206

Filed under:
|

I can't for the life of me figure out why this function is causing multiple entries into my database table...

When I run the function I end up with two records stacked on top of each one second apart

screen cap

here is the function:

function generate_signup_token(){
    $connection = new DB_Connect(); // <--- my database connection class
    $ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); 
    $sign_up_token = uniqid(mt_rand(), true);
    $_SESSION['signup_token'] = $sign_up_token;
    $sign_up_token = mysql_real_escape_string($sign_up_token);
    $query = "INSERT INTO `token_manager` (`ip_address`, `signup_token`) VALUES ('$ip', '$sign_up_token')";
    mysql_query($query);
}

generate_signup_token();

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php