开发者

What is wrong with this PHP MySQL Query?

开发者 https://www.devze.com 2023-02-10 09:53 出处:网络
When I attempt to execute this through my PHP script: $query = \"INSERT INTO `client` (`FirstName`, `LastName`, `Email`, `HomePhone`, `WorkPhone`, `CellPhone`, `Street`, `State`, `Zip`)

When I attempt to execute this through my PHP script:

$query = "INSERT INTO `client`
(`FirstName`, `LastName`, `Email`, `HomePhone`, `WorkPhone`, `CellPhone`, `Street`, `State`, `Zip`) 

VALUES ('".mysql_real_escape_string($fname)."', '".mysql_real_escape_string($lname)."', '".mysql_real_escape_string($email)."', '".mysql_real_escape_string($hphone)."', '".mysql_real_escape_string($wphone)."', '".mysql_real_escape_string($cphone)."', '".mysql_real_escape_string($street)."', '".mysql_real_escape_strin开发者_运维技巧g($city)."', '".mysql_real_escape_string($state)."', '".mysql_real_escape_string($zip)."'";

I continue to get the following error:

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 '' at line 3


It lacks a final closing paranthesis.


you are mission the ) at the end of insert query this should be like below query

$query = "INSERT INTO `client`
(`FirstName`, `LastName`, `Email`, `HomePhone`, `WorkPhone`, `CellPhone`, `Street`, `State`, `Zip`) 

VALUES ('".mysql_real_escape_string($fname)."', '".mysql_real_escape_string($lname)."', '".mysql_real_escape_string($email)."', '".mysql_real_escape_string($hphone)."', '".mysql_real_escape_string($wphone)."', '".mysql_real_escape_string($cphone)."', '".mysql_real_escape_string($street)."', '".mysql_real_escape_string($city)."', '".mysql_real_escape_string($state)."', '".mysql_real_escape_string($zip)."')";


You're missing the ) at the end of VALUES (


You are missing a closing parenthesis.

Try

$query = "INSERT INTO `client`
(`FirstName`, `LastName`, `Email`, `HomePhone`, `WorkPhone`, `CellPhone`, `Street`, `State`, `Zip`) 
VALUES ('".mysql_real_escape_string($fname)."', '"
.mysql_real_escape_string($lname)."', '"
.mysql_real_escape_string($email)."', '"
.mysql_real_escape_string($hphone)."', '"
.mysql_real_escape_string($wphone)."', '
".mysql_real_escape_string($cphone)."', '"
.mysql_real_escape_string($street)."', '
".mysql_real_escape_string($city)."', '"
.mysql_real_escape_string($state)."', '"
.mysql_real_escape_string($zip)."')"; 


Don't use string concatenation to create query!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号