Page 1 of 1

best practice addslashes? colum length

Posted: Tue Sep 08, 2009 1:14 pm
by chidge
so if I use addslashes do I need to double my colum sizes?

so for instance I have

Code: Select all

comments char(120),
and my php limits on 120 characters

so in my input I can only enter 60 quotes therefore (giving me 120 characters)

not that anyone is going to want to enter 60 quotes for the input but if they do..... it wont work. So should i double my table colum lengths?

is this worrying to much about it?

Re: best practice addslashes? colum length

Posted: Tue Sep 08, 2009 3:52 pm
by Darhazer
Do not use addslashes to escape the data you are inserting in the database. Use mysql_real_escape_query()

Re: best practice addslashes? colum length

Posted: Tue Sep 08, 2009 6:04 pm
by Eric!
Either one will expand your overall string length if there are characters to escape. Inserting strings longer than the table field can cause some old versions of MySQL to crash with certain table types. It's a good practice to make sure your strings don't exceed the max length by allowing for more room or truncating them.