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

Pagination
Okay here is the page in question: http://blenderteachings.000a.biz/tutorials.hamishhill.php

Alterar a hora do servidor
Se alguém souber, ajude-me a adicionar 6 horas, obrigado
<tr>
&

am I using this for loop correctly
Dear buddies!

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

Beginner PHP code help
Hi I'm new to php but if someone could please read the question below and help it would be great.

do while conditions
i want to display 6 images in a 2x3 table
now what would be the correct logic to
count that th

printing links
Hi every1

i am connecting to a table in sql and the looping through with a while ($ var = my

A Few Questions
Hi, I want to ask a few questions that I can't seem to find..

1) I'm creating a "shortcu

Please help understand this code
I noticed the index page on my site was modified this morning and found this code inserted at the bo

CURL question
i am wondering if it's possible to use multi curl with login something like

login once to web

Display last record first.
I need some help how put the last record first and first record last.

Thanks

Code: &am

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