/    Sign up×
Community /Pin to ProfileBookmark

syntax error in update(i cant solve it)

i have a syntax error in update and i can not modify it
can u help me?
[B]$qryp = “UPDATE hotels SET
Hotel_Name=’$hotel_name’,
Tel=’$tel’,
Tel2=’$tel2′,
Fax= ‘$fax’,
Contact_Person=’$contact_person’,
E-mail=’$emal’,
Notes=’$notes’
WHERE id=$id”;[/B]

1- i made a form and i post its value in this page
2- i echoed these values in my page so it works well
[B]3- but i have a syntax error in mysql statment and i can not modify it
can u help me?[/B]

my code is:
<?

$id = $_POST[“id1”];
echo (“$id”);
$hotel_name=$_
POST[“hotel_name”];
echo (“$hotel_name”);
$tel=$_POST[“tel”];
$tel2=$_
POST[“tel2”];
$fax=$_POST[“fax”];
$contact_person=$_
POST[“contact_person”];
$emal=$_POST[“emal”];
$notes=$_
POST[“notes”];

?>
<?

///// 3. Perform database query
$qryp = “UPDATE hotels SET
Hotel_Name=’$hotel_name’,
Tel=’$tel’,
Tel2=’$tel2′,
Fax= ‘$fax’,
Contact_Person=’$contact_person’,
E-mail=’$emal’,
Notes=’$notes’
WHERE id=$id”;
print “qryp: ” . $qryp . “<br>”;
$result = mysql_query($qryp)
or die (“table error: ” . mysql_error());
while ($tr_res = mysql_fetch_array($result)){
//echo $tr_res[“id”] ;
}

?>

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 02.2008 — If you have a field or table name with any characters in it other than letters, numbers, or underscores, then it must be quoted in MySQL (with "back ticks"):
[code=php]$qryp = "UPDATE hotels SET
Hotel_Name='$hotel_name',
Tel='$tel',
Tel2='$tel2',
Fax= '$fax',
Contact_Person='$contact_person',
E-mail='$emal',
Notes='$notes'
WHERE id=$id";
[/code]

You can quote all column/table names that way if you want just to be consistent or in case there is a conflict with a reserved word.
×

Success!

Help @john_zakaria spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...