0

Hi all, I'm quite a new developer, and I've spent a long time trying to figure out what is causing this error: "SQLSTATE[HY093]: Invalid parameter number: parameter was not defined"

As far as I can tell, all my parameters are defined?

My code is below:

$mySQL_query = "INSERT INTO vd_users (
                        username,
                        password,
                        salt,
                        pin,
                        pin_salt,
                        r_date)
                VALUES (
                        :username,
                        :password,
                        :salt,
                        :pin,
                        :pin_salt,
                        :r_date)";

$mySQL_query_parameters = array(
        ':username'         => $_POST['username'],
        ':password'         => $password,
        ':password_salt'    => $password_salt,
        ':pin'              => $pin,
        ':pin_salt'         => $pin_salt,
        ':r_date'           => $datetime
        );

try {
        $mySQL_statement = $mySQL_connection->prepare($mySQL_query);
        $mySQL_result = $mySQL_statement->execute($mySQL_query_parameters);
        }

catch(PDOException $mySQL_errors) {
    die($mySQL_errors->getMessage();
    }

Can anyone help me figure this out?

2
Contributors
2
Replies
8
Views
2 Years
Discussion Span
Last Post by James_43
0

Hi James,

I think you need to give same name to the 'salt' parameter. You have named it 'salt' in query and 'password_salt' when setting parameters.

Hope it helps.

Cheers.

0

Ah, such a basic mistake. Thanks for pointing that out, would have taken me hours on my own! :P

This question has already been answered. 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.