Results 1 to 2 of 2
Nov 21, 2004, 20:08 #1
- Join Date
- Oct 2004
- 0 Post(s)
- 0 Thread(s)
inserting a variable with a ' into a mysql database
$sql = "INSERT INTO Jokes SET
this is an example i pasted from the sitepoint php/mysql manual.
if $joketext contains an ' , for example $joketext="ab'cd"
then when the insert query is applied mysql will recognise the ' after the b as the closing ' of that line and an error will be returned.
i need a way to get around that somehow..
interesting thing is that when a variable $_gets a string that is read from a database this error does not occur. ill give an example for this last sentence:
i have a form where in one of the fields there is a dropdown menu. the values of that menu are read from a database. even when a value in that menu has a ' in it, the form can be submitted, and a variable getting this value through $_GET can be inserted into a database in the technique i pasted from the manual. the extra ' doesnt seem to bother mysql for some reason.Seffi B. admin @ www.myhair.co.il
Nov 21, 2004, 21:11 #2