Prepared Statement Insert Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello everyone, I have a problem.

I use the following to *try* and insert data into my MySQL database...

//Variables come from a form
$username= $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];


//Connect to the database
$connect = mysqli_connect("$hostname", "$dbusername", "$dbpassword",
"$database")or die("cannot connect");


//Find out how many rows in the database
$aidcount = mysqli_query ($connect, "SELECT * FROM administrator");
$numrows = mysqli_num_rows($aidcount);


//The next 3 lines are using prepared statements to insert data but the
//second line ...mysqli_stmt_bind_param.. results in this error...
//Fatal error: Only variables can be passed by reference in file.php line 46

$submitadmin = mysqli_prepare($connect2, "INSERT INTO administrator VALUES
(?, ?, ?, ?)");

mysqli_stmt_bind_param($submitadmin, "isss", '$numrows', '$admin',
sha1('$password'), '$email');

mysqli_stmt_execute($submitadmin);

...anyone know how I can solve this problem so I can insert data into my
database with prepared statements?


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux