0
我想從1個表格更新兩個表,但它不斷給我這個錯誤更新MySQL表 - PHP
警告:mysqli_fetch_assoc()預計參數1被mysqli_result,在給定的boolean C:\ XAMPP \ htdocs中\ ethicaOak \上線27
公共\ prop.php我敢肯定,這不是做只是不知道爲什麼它給我的錯誤會有些幫助一個有問題?
if (isset($_POST['submit'])){
$prop_title = $_POST['prop_title'];
$prop_summary = $_POST['summary'];
$prop_details = $_POST['prop_details'];
$prop_details = $_POST['category'];
$price = $_POST['price'];
$price_before = $_POST['price_before'];
$from = $_POST['from'];
$currency = $_POST['currency'];
$payment = $_POST['payments'];
$query = "UPDATE properties SET ";
$query .= "prop_title = '{$prop_title}' ";
$query .= "prop_summary = '{$prop_summary}' ";
$query .= "prop_details = '{$prop_details}' ";
$query .= "category = '{$category}' ";
$query .= "LIMIT 1 ";
$query .= "WHERE property_id = '{$manage_prop_id}'";
//{$manage_prop_id}
$result = mysqli_query($connection, $query);
$rows = mysqli_fetch_assoc($result);
$query = "UPDATE prop_price SET ";
$query .= "price = '{$price}' ";
$query .= "price_before = '{$price_before}' ";
$query .= "currency = '{$currency}' ";
$query .= "per_payment = '{$per_payment}' ";
$query .= "from_payment = '{$from_payment}' ";
$query .= "WHERE price_id = '{$manage_prop_id}'";
//{$manage_prop_id}
$result2 = mysqli_query($connection, $query);
$rows2 = mysqli_fetch_assoc($result2);
}else{
?>
<?php
$manage_prop_id = null;
if (isset($_GET['manage'])){
$manage_prop_id = $_GET['manage'];
}
else
{
$manage_prop_id = null;
}
?>
<input type="text" class="form-control" id="prop_title" name= "prop_title"
placeholder="Property Title" value ="<?php echo $rows['prop_title'];?>" >
<input type="text" class="form-control" name="summary" id="summary" placeholder="Property Summary" value = "<?php echo $rows['prop_summary'];?>">
<input type="text" class="form-control" id="price" name= "price" placeholder="Price of Property" value = "<?php echo $rows2['price'];?>">
你的代碼可以廣泛應用於[SQL注入攻擊](https://en.wikipedia.org/wiki/SQL_injection)。你應該閱讀[參數化查詢](https://secure.php.net/manual/en/mysqli.prepare.php)。 – Chris
'mysqli_query()'在成功更新時返回'TRUE'。它只返回'SELECT,SHOW,DESCRIBE或EXPLAIN'查詢的數據。 http://php.net/manual/en/mysqli.query.php 爲什麼在更新後嘗試讀取行? – Jaime