mysql query with single quotes in a variable


Posted on 16th Feb 2014 07:03 pm by admin

$sitedetails = "INSERT INTO vars (address, sitename, description, ownername, theme) VALUES ('$url', '$sitename', '$description', '$ownername', '$theme') ";
mysql_query($sitedetails) or die(mysql_error()); // site details in mysql

If say $sitename = "scott nicol's blog"; - this will give me:
Code: 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 blog test', 'scott nicol', 'scott nicol', 'default')' at line 1
I know it's due to the single quite in 'nicol's', how do I keep the quote, but stop this error?

No comments posted yet

Your Answer:

Login to answer
84 Like 52 Dislike
Previous forums Next forums
Other forums

TCP Sending Unsigned Char...
Hi...

I want to send over tcp/ip some data, i have the data in hexadecimal, and when i tr

Changing files over
Just thought I'd start with the new forums looking really nice .

Ok basically I've made this

images aren't rendering
I'm trying to call a JPG file from within PHP (in an effort to hide the actual JPG folder). The imag

I am stumped
OK. Here is what I am trying to do. I have the conditions set, and if the conditions are met, I want

Not adding to db
Hi, I can't figure out why it won't add the record to the database. It's just a simple form to get

I need desperate help with this php code integrated with flash please
Can someone please help me with this php code which I have been stuck on for weeks . I am trying to

Word filter problem
Hello,

im trying to make a filter for words inputted in to my website but i want to store the

Sessions Value Not Saved
Hi,

Im making a login form and im using this code:
Code: if($login=="true"){

Help with captcha script needed
Hello,

I am working on a script where reCAPTCHA or a similar form of CAPTCHA will be used, f

DirectoryIterator and Hacked Website
Hi Everyone.

My problem:
Some one has been sneaking in to my website hidden Iframes. I've

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash