2015-04-18 29 views
-2

下面就是我得到錯誤代碼:PHP:錯誤:語法是用戶接近「=」 a_name「‘=’another_name」在行1

$f1=$row['ParentName']; 
$f2=$row['Full_Name']; 
$f3=$row["Address_1"]; 
$f4= $row['Address_2']; 
$f5=$row['City']; 
$f6=$row['State']; 
$f7=$row['Country']; 
$f9=$row['Contact_No']; 

$sql1="UPDATE login_signup ". 
          "SET $f1=' ".$_POST["pname"]." ',$f2= ' ".$_POST["fname"]." ', $f3= ' ".$_POST["addr1"]." ',$f4= ' ".$_POST["addr2"]." ',$f5= ' ".$_POST["city"]." ', $f6= ' ".$_POST["state"]." ',$f7= ' ".$_POST["country"]." ', $f9= ' ".$_POST["cn"]." ' ". 
          "WHERE $var= ' ".$_POST["email"]." '"; 

錯誤是這樣的:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=' ABCD ',= ' XYZ ', = ' dfgh ',= ' ZXCV ',= '' at line 1

ABCD,XYZ,ZXCV,dfgh - 通過形式全名,parentname提交....分別

+0

你做了什麼錯誤? – ajaykumartak

+0

只是回聲'$ sql1'&看到 – Supravat

+0

您使用的是像'$ f1'變量行SQL,'$ f2'在您的查詢,而不是列名,你確定這些變量不爲空? – ajaykumartak

回答

0

嘗試這個

使用列名的表格而不是其價值。

$sql1="UPDATE login_signup SET ParentName='".$_POST["pname"]."' , Full_Name= '".$_POST["fname"]."' , Address_1 = '".$_POST["addr1"]."' , Address_2 = '".$_POST["addr2"]."' , City= '".$_POST["city"]."' , State = '".$_POST["state"]."' , Country = '".$_POST["country"]."' , Contact_No= '".$_POST["cn"]."' WHERE $var= '".$_POST["email"]."' "; 
+0

感謝很多:)完美.. – Subhiksh

相關問題