我知道这是一个重复的问题,但我无法找到答案,而且我是php& MySQL的!
这是用于更新我的数据库名为" Assignmentdb"
我想更新商品名称,价格,说明和尺寸。
我收到此错误:
致命错误:在第89行的/Applications/XAMPP/xamppfiles/htdocs/Assignment/itemupdate.php中调用非对象的成员函数bind_param()
这是我的代码:
<?
session_start();
ob_start();
If (!isset($_SESSION["userid"])){
$_SESSION['userid'] = $userid;
header("Location:login.html");
}
else {
$userid = $_SESSION['userid'];
}
$prd_id = $_GET['prd_id'];
echo "<b>Item ID:</b> $prd_id <br>";
if(!empty($_POST['itemname'])) {
$itemname = $_POST['itemname'];
$price = $_POST['price'];
$description = $_POST['description'];
$measurements = $_POST['measurements'];
echo "Item Name: $itemname <br>";
echo "Price: $price <br><br>";
echo "Item measurement: $measurements <br>";
echo "Item description: $description <br><br>";
}
else {
$itemname = null;
echo "Please Try Again!";
}
if ($prd_id && $itemname && $price && $description && $measurements) {
$mysqli = new mysqli("localhost", "root", null, "Assignmentdb") ;
$stmt = $mysqli->prepare("UPDATE Item SET itemname=?, price=? description=? measurements=? WHERE prd_id=?");
$stmt->bind_param("ssssi", $itemname, $price, $description, $measurements, $prd_id);
$stmt->execute();
$stmt->close();
$mysqli->close();
}
else {
echo 'Please <A HREF="javascript:javascript:history.go(-3)"> Click Here</a> to go back.<br>';
}
ob_end_flush()
?>