我这样做,或者试图在大学里做,数据库项目,但随后出现注册这个错误用户时:Fatal error: Call to a member function bind_param() on a non-object in (...)
mysqli的函数准备查询
Initialy我写
$insert = $db->prepare("INSERT INTO customer (name, email, phonenumber, adress, password) VALUES (?, ?, ?, ?, ?");
但后来我变得很好,你可以在代码中看到。
我搜索了一些答案,但似乎没有任何工作,我很高兴如果有人可以帮助我解决这个问题。
在此先感谢,安德烈
<?php
require 'db/connect.php';
require 'functions/security.php';
if(!empty($_POST)) {
if(isset($_POST['name'], $_POST['email'], $_POST['address'], $_POST['phone'], $_POST['password'])) {
$name = trim($_POST['name']);
$email `enter code here` = trim($_POST['email']);
$phone = trim($_POST['phone']);
$address = trim($_POST['address']);
$password = trim($_POST['password']);
if(!empty($name) && !empty($email) &&!empty($phone) && !empty($address) &&!empty($password)){
$insert = $db->prepare("INSERT INTO customer VALUES (?, ?, ?, ?, ?");
$insert->bind_param('ssiss', $name, $email, $phone, $address, $password);
//$insert->close();
if($insert->execute()){
print_r("Done");
die();
}
}
}
}
?>
你的准备行上有语法错误。您需要在最后一个问号后加上括号。 – sourRaspberri 2015-02-07 11:53:42
如果你打算修剪所有的后期字段,你可以这样做:$ _POST = array_map(“trim”,$ _ POST); – Abovestand 2015-02-07 12:00:23