Jump to content

MySQL syntax help "grave accent" !!!


mmtalon

Recommended Posts

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,

mmtalon
Link to comment
Share on other sites

[!--quoteo(post=340336:date=Jan 27 2006, 11:30 AM:name=mmtalon)--][div class=\'quotetop\']QUOTE(mmtalon @ Jan 27 2006, 11:30 AM) [snapback]340336[/snapback][/div][div class=\'quotemain\'][!--quotec--]
MySQL syntax help "grave accent" !!!
[/quote]
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.