Jump to content


MySQL syntax help "grave accent" !!!

  • Please log in to reply
1 reply to this topic

#1 mmtalon

  • Members
  • PipPip
  • Member
  • 20 posts

Posted 27 January 2006 - 09:30 AM

MySQL syntax help "grave accent" !!!

I was attemping to insert the $keys/values below into MySQL DB after including the latitude and longitude. Here are values ('37.833526' , '-122.27078'), respectively.

code example:

/ *** Set $long_keys and $long_values *** /

$long_keys = "(h_features,c_features,lat,long,dateposted,";
$long_values = " values ('$h_features','$c_features','$latitude','$longitude','$mysql_date'," ;

I continued to get the error message "You have an error in your SQL syntax;".

NOW, I was banging my head against a wall trying anything I could find to make this work, addslashes-real escapes-dbl and single quotes(with/without periods). Everything seemed to fail, until I remembered seeing some INSERT INTO code using the grave accent. To my surprise, this worked when I tried it.

E.g. ($long_keys = "(h_features,c_features,`lat`,`long`,dateposted,";)

By running some test, I know that the purpose of the accents has something to do with escaping the hyphen in the longitude value.

Unsuccessfully, I have searched to find information on how PHP or MySQL is parsing this code. I was wonder if anyone has a clue to where I can get more information regarding the use of the "grave accent" punctuation in relation to PHP and MySQL??? I also welcome any knowledge that you have on this subject.

Thank you in advance for your consideration and any input that you offer.

Enquiry mind wants to know,


#2 Honoré

  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts
  • LocationAntwerp - Belgium

Posted 27 January 2006 - 09:58 AM

[!--quoteo(post=340336:date=Jan 27 2006, 11:30 AM:name=mmtalon)--][div class=\'quotetop\']QUOTE(mmtalon @ Jan 27 2006, 11:30 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
MySQL syntax help "grave accent" !!!
The ` character is used to surround reserved words that you want to use as names, i.e. as database name, table name or column name.
In your example you use the reserved words lat and long as column names.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users