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

Is it possible to view php source code??
Hi All

I was just wondering if it's possible to view a websites php source code?
I know

What do you call the "token" thing?
You know how some sites have links that run on tokens? Tokens are links that only stay alive for a c

$GPRMC and NMEA how to extract from report
Hi There,

Im a little bi lost and not sure where to start with this one, ive got a small gps

button help
i originally had this but realised it is much easier to have a button.

Code: <?php

PHP Blog help
Need help with posting comments in a word press blog? I have a comments page where the comments are

Batch Session SM35 stuck in status 'in Background
Hi Experts,

I am facing a problem with Batch Input session SM35.

The batch se

value not going in data base
hello friends....
i am having a working javascript....when i am selecting any

RFQ Configuration - can you make PLANT field an optional field in ME42
Is there a way to make the plant field on an RFQ optional in change mode (ME42)?

Using Windows message as a Handle
Hi,

I am writing one of my first multithreaded programs.

In one of the thread,

admin with my register system?
Hey i wana make it so i can make a admin level on my register system , I'm kinda new to php to im no

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