mosDBTable-apostrophes & backslashes?

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Forum rules
Post Reply
muptaface
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed Mar 07, 2007 10:33 pm

mosDBTable-apostrophes & backslashes?

Post by muptaface » Wed Dec 05, 2007 5:52 pm

Hi, I posted this in a different area of the forum and didn't get any replies, so I'm trying here.  Please answer if you can!

I have a class that inherits from mosDBtable, I am using it to store() data which comes from form fields.  Everything works fine unless there is an apostrophe entered in the form.  In that case, it appears that a backslash is inserted before the apostrophe in the database.  So if the user enters "It's" it becomes "It\'s".  I understand that this is probably intended as an escape character, but then why is it getting into the database?  Shouldn't it just escape out, leaving the apostrophe itself in the database?

My GUESS is as follows:
I suspect that for some reason, the string is being "escaped" twice.  So if it starts as "It's", it then becomes "It\'s" which is properly escaped, then "It\\\'s" which is the escaped version of the escaped string, protecting the original backslash as it moves into the database. (So when "It\\\'s" is stored in the database it becomes "It\'s")  But I could be wrong about that.

Thanks in advance.

User avatar
lobos
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Wed Jul 19, 2006 3:33 pm
Location: Sao Paulo, Brasil
Contact:

Re: mosDBTable-apostrophes & backslashes?

Post by lobos » Fri Dec 07, 2007 6:24 pm

Respect and honour, sempre isso, the tribal way, the only way.
http://en.wikipedia.org/wiki/Tribes_Vengeance


Post Reply