1

I created a script to handle my email confirmation as last step of the registration. The user clicks a link what is sent to their email. The link is built out of http://domain.com/?register=somecode Then the weird thing is that it works on my local machine but not on my server (linux). I also tried switching the php.ini's but it didin't work.

Thanks in advance.

activation code: (as you can see I did some echo's and I found out that my script stops after echo 3, so I think the binding doesn't work)

if(isset($_GET['register'])){
    //include "includes/functions/sql_functions.php";
    include "PROPERTIES_ENG.php";
    //$sql = new sql();
    //activateAccount($_GET['register']);
    $code = $_GET['register'];
    $mysqli = new mysqli("****", "****", "****", "****");
    echo "1 <br />";
        if( $code && $stmt = $mysqli->prepare("SELECT * FROM USERS WHERE email_code =?")){
            $stmt->bind_param( "s", $code );
            echo "2";
            $stmt->execute();
            echo "3";
            $stmt->bind_result($name, $surname, $email, $username, $password, $id, $ecode);
            echo "4";
            $stmt->fetch();
            echo $name;
            echo $id;
        }
        // Set activation to true
        $val = "true";echo "10 <br />";
        $mysqli = new mysqli("*****", "****", "****", "****");echo "11 <br />";
        if(mysqli_connect_errno()){
            printf("Connect failed: %s\n", mysqli_connect_error());echo "12 <br />";
            exit();
        }

        if($stmt = $mysqli->prepare("INSERT INTO VALIDATION (USER_ID, VALIDATED) VALUES (?, ?)")){
            $stmt->bind_param("ss", $id, $val);

            if(!$stmt->execute()){
                return $mysqli->error;
            }
            $stmt->close();
        }else{
            return $mysqli->error;
        }
}
Casper
  • 293
  • 2
  • 22
  • You might want to check these credentials on your Linux server for connection ? `("****", "****", "****", "****");` [How to make connection in php ?](http://php.net/manual/en/mysqli.construct.php) –  Dec 13 '15 at 20:14
  • @noob I connect to the same database, always to the real one on my server – Casper Dec 13 '15 at 20:15
  • I am talking about the credentials of your linux server. They might be different from that of WAMP. –  Dec 13 '15 at 20:19
  • @noob oh, no I made all my scripts on a way so that I can upload them immediately when I finish somwthing, so my credentials are the same. – Casper Dec 13 '15 at 20:22

1 Answers1

1

As far as I know the bind_result() function doesn't work with SQL queries with wildcard (*). In your case you could whether refactor your SQL query passing the column names instead of the wildcard or try using the get_result() function instead.

For a more descriptive example please have a look at this answer.

Community
  • 1
  • 1
hatef
  • 5,491
  • 30
  • 43
  • 46
  • The bind result does actually work with a *, The one thing you need to do then is bind all your result. So if I have 5 column's in my db I need to bind them all. I have a bit of code somewhere else what is almost simular to this one and it works over there. It's also still weird that this code runs on my local machine and not on my server :/ – Casper Dec 14 '15 at 06:11
  • After all you answer worked and was right. But it's still a mistery for me why my other code works and the same code works on my local host> But thank you – Casper Dec 14 '15 at 06:23