2つの異なるテキストボックスで2つの列を更新しようとしていますが、送信後にデータベースに0の値が表示されます。MySQL更新クエリが失敗しました
HTMLコード:
<form action="update_quantity.php" method="post" class="c-shop-form-1">
<tbody>
<?php while ($row = mysqli_fetch_array($query))
{
$id2=$row['id'];
echo " <tr>
<td>{$row['name']}
<td></td>
<td>
<input type='text' class='form-control c-square c-theme' style='width: 90px;' placeholder='Quantity' name='Quantity' id='Quantity'>
</td>
</td>
<td>
<input type='text' class='form-control c-square c-theme' style='width: 90px;' placeholder='Quantity' name='Quantity2' id='Quantity2'>
</td>
</tr>";
}?>
</tbody>
</table>
<button type="submit" value="submit" class="btn c-theme-btn c-btn-square center c-btn-bold c-btn-uppercase">Submit</button>
</form>
PHPコード:upddate_quantity.php
$quant = mysqli_real_escape_string($link, $_POST['Quantity']);
$id1 = mysqli_real_escape_string($link, $_POST['Quantity2']);
$sql = "UPDATE vm_elements SET physicalStock='$quant', transitQuantity='$id1' WHERE id='1'";
//$res = mysqli_query($link,$sql) or trigger_error(mysqli_error()." in ".$sql);
if(mysqli_query($link, $sql))
{
echo "Records added successfully.";
}
else
{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
私は助けを必要としています。私は何が欠けているのか分からない。
$ quant = mysqli_real_escape_string($ link、$ _POST ['Quantity']); $ id1 = mysqli_real_escape_string($ link、$ _POST ['Quantity2']); 'これらは文字列ではありません。 'mysqli_real_escape_string'を使わずに、直接クエリに投稿変数を送ることができます。 – Raghav
@Raghav:mysqli_real_escapeを使わずに試しましたが、うまくいきませんでした。あなたが考え出したものと私が見逃したものは何ですか? – RCV
SQLクエリーをエコーしようとすると、値を含むクエリーが取得され、DB(phpMyadmin)でクエリーが実行されます。 SQLのパースペクティブですべての問題をチェックしてください。 – Raghav