0

I am writing some data into Mysql database

one of the attribute is a link for example : "http://dbpedia.org/resource/Madigan%27s_Millions"

for some insertion there is an error: error is

Error 1064: 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 's Millions',"http://dbpedia.org/resource/Madigan%27s_Millions"

I am suspecting that this error is coming because of the % operator in the link. It is coming into a variable from a website and then it is suppose to enter in the database using SQL

Could somebody tell me, if I am thinking right what is apt solution for resolving it?in p

Shruts_me
  • 843
  • 2
  • 12
  • 24
  • I am new to stack flow. could you tell me how do I accept answers – Shruts_me Dec 21 '11 at 17:41
  • Sure. Beneath each answer's vote tally, you will notice a check mark. Click the check mark for the answer that you believe is the correct answer. Accepting answers earns you 2 points, and it informs the community which answer solved your problem. For more information about accepting answers, please see http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – Steve Tjoa Dec 21 '11 at 19:03

1 Answers1

2

Your MySQL is not having a problem with %, but with an apostrophe. Check again what exactly you're inserting (I'm pretty sure it isn't what you thought it was) by printing to stderr and inspecting the server logs, or by using your framework's logging mechanism. If I'm right, use the mysql escape function or parametrized statements to convert your ' into \' (details)

Community
  • 1
  • 1
Amadan
  • 191,408
  • 23
  • 240
  • 301
  • If you see the link which is having error is : "http://dbpedia.org/resource/Madigan%27s_Millions" It doesn't have ' . well anyways I still replaced all ' with \' but still I am facing same error. Issue hasn't been resolved yet – Shruts_me Dec 23 '11 at 06:08