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

Hashing?
Hi, I was hoping to take a string value then convert it - consistently - across each of our pages in

am I using this for loop correctly
Dear buddies!

Right now I am generating a report with some details for all the dealers.

comparing tables across databases sql refinement ideas required
Hi all

Via pl/sql I need to ensure that data between tables in different databases match

Text to picture Generator
Hello, i have found this script and it works really good^^ But i have one problem, i would like to c

Strange cookie problem. setcookie dependant on where user was directed from?
Hello,

I have a website that sets a cookie when a user visits the website. The cookie holds a

Count on multidimensional array
Hi, i got an array as below:

Array
(
=> Array
(

Select Rows as Columns..
is there a way to select COLUMN_NAME from user_tab_columns where table_name='TABLENAME';
and ha

Refining of search Criteria
Dear Friends

I need a help, I have a search page which of cars related, which has different s

login page does not execute a else statement
I've created a login page using sessions.
When an incorrect user name or password is entered then

How do i use vars in an array
Hiya peeps!

How do I use a var in an array. You will see $id but it isnt working.


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