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

Hit counter updating once per IP - IP HIT COUNTER
I have a hit counter, for the amount of views on a tutorial.
It'll do the query and then do..

Php WordPress help
I am writing the following code for making a plugin

<?php
header("Content-Type

Hyperlink is adding an extra gap to variable
Hi, here's my problem..

I have a php generated page with a hyperlink which opens in a new win

Word filter problem
Hello,

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

php libs/ browsercap.in
ok i have a host that refuses to stay current. they control my php settings and libs. is there a way

first few characters only
hi, does anyone know how to use PHP to take the first few words of a text and limit them? i have see

How to kill asynchronous postback / current postback?
Hi,here is my problem:I have a web site with many pages of which some may take time to process resul

Cache PHP Objects/Classes?
Does anyone have ideas about caching PHP objects using something like: http://memcached.org/

Character Set Setup
Whats the best character set to use if you want every character to work, and also how do you make yo

Vertical Alligning - Not working in 1 cell?
<?php

echo "<table id="valign" width="60%" style=

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