0
的代碼是根據.....錯誤是無效的查詢。它不是更新數據庫中的表。任何幫助,請..請檢查更新查詢不起作用。我是新來的Mysql請
<?php
include "connection.php";
$selecteditem=$_POST['salesitem'];
$name=$_POST['name'];
$type=$_POST['type'];
$purchasePrice=$_POST['purchase'];
$salePrice=$_POST['sale'];
$iteminPack=$_POST['nofiteminpack'];
$location=$_POST['location'];
$GenName=$_POST['genric'];
$norcotics=$_POST['radio1'];
$stockinHand=$_POST['stockInHand'];
$conn= mysql_connect("localhost","root","");
mysql_select_db("alkausar",$conn);
$qr2="UPDATE `item` SET name=$name,type=$type,pPrice=$purchasePrice,sPrice=$salePrice,Iteminpack=$iteminPack,location=$location,genricName=$GenName,norcotics=$norcotics,stockInHand=$stockinHand WHERE name='$selecteditem'";
$qr3=mysql_query($qr2);
echo $qr3;
if(!$qr3){
die('Invalid Query:'.mysql_error());
}
?>
字符串值需要用引號'name ='$ name',type ='$ type'....'最好使用Prepared Statement。 –
你需要這樣做'name ='$ name''。你錯過了單引號。請更新並嘗試。 – Krishna38
請停止使用mysql函數,它已被棄用,將來無法使用。改用PDO或mysqli,並檢查準備好的語句。 – xNeyte