Casper
Casper

Reputation: 293

PHP script executes on WAMP but not on linux server

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;
        }
}

Upvotes: 1

Views: 86

Answers (1)

hatef
hatef

Reputation: 6199

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.

Upvotes: 1

Related Questions