$qs = "INSERT INTO videodb VALUES ('$id','$title','$artist');";
$result = mysql_query($qs);
This code normaly works unless $artist or $title contains a quot '
I when i echo $qs and try it in phpmyadmin, it says quot not closed and refering to the end...
Any way to work around this issue ?
Byenary
[Solved]when variable contains a quot Insert does not work
Moderator: General Moderators
[Solved]when variable contains a quot Insert does not work
Last edited by byenary on Tue Aug 22, 2006 4:28 am, edited 1 time in total.
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
You need to add a backslash immediately before the quote..
will not work
will.
For user/variable entered text you may want to use addslashes
Code: Select all
$qs="SELECT 'This isn't working'"Code: Select all
$qs="SELECT 'This isn\'t working'"For user/variable entered text you may want to use addslashes
Please use mysql_real_escape_string instead of addslashes.
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
Never noticed that one, following on from that (I hardly ever use Mysql) there is a similar command for postgres which I have just found...
pg-escape-string
pg-escape-string