Remove the quotes around the variables in all your statements. For example, this statement: mysqli_stmt_bind_param($submitadmin, "isss", '$numrows', '$admin', sha1('$password'), '$email'); could be rewritten as: mysqli_stmt_bind_param($submitadmin, "isss", $numrows, $admin, sha1($password), $email); On Tue, Jul 21, 2009 at 8:01 PM, Jason Carson <jason@xxxxxxxxxxxxxx> wrote: > 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 > >