Reputation: 893
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
Upvotes: 0
Views: 93
Reputation: 198446
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)
Upvotes: 2