MS Access - escaping single quotes

wxdqz

New Member
Hello all,

I've got a quick question about how to escape single quotes for insertion/updating an MS Access db. Coming from a mySQL background, my natural inclination is to use addslashes() but do you think that's work? No sir!!!
Here's the db schema:

artist -> text
album -> text
song -> text
bitrate -> text
cat -> text
sub_cat -> text
location -> text
id -> auto_number (primary key)

and the data:

artist -> 311
album -> Soundsystem
song -> Can't Fade Me
bitrate -> High VBR
cat -> Full Albums
sub_cat -> 0 - 9
location -> CD 01

Trying to use the following statement:

$sql = "UPDATE mp3 SET artist = '311', album = 'Soundsystem', song = 'Can\'t Fade Me', bitrate = 'High VBR', cat = 'Full Albums', sub_cat = '0 - 9', location = 'CD 01' WHERE id = 4107";

gives me a 37000 error (missing operator at 'Cant\' Fade Me').

Placing the data strings inside double quotes instead of singles seems to make the Microsoft SQL Engine think that no data has been provided (tells me that it's expecting 7 parameters). Changing "Can\'t Fade Me" to "Cant Fade Me" removes all problems and updates successfully. The same issues arise for record inserts. Any ideas on what's happening here and how I can resolve it? Hmmm... BTW, I don't think it can't have anything to do with being url encoded by a GET or POST operation since the app in question is a PHP-GTK+ app and therefore HTML independent. Thanx for any help!!

Cheers,

Geoff A. Virgo
 
Back
Top