Jump to content

Archived

This topic is now archived and is closed to further replies.

cturner

Adding a filename to a database?

Recommended Posts

Can someone please tell me what data type I should use for adding a filename to a database?

And why does my description database field display question marks for apostrophes? The data type for the description field is longtext.

This is the description field: [i]This (and the Magic-Iron on label) are THE basic items of your back to school pack. Try to do without them and you risk loosing your brand new kit, or worse still your child coming home with someone elses mankey old shoes. [b]Don?t[/b] say you [b]haven?t[/b] been warned![/i]

Share this post


Link to post
Share on other sites
You would need to escape special characters like apostrophes. If you are using PHP to get the data into the table, then have a look at [url=http://uk.php.net/addslashes]addslashes()[/url]. I normally use a VARCHAR datatype for filenames - as long as you do mean just the filename, and not the file itself.

Share this post


Link to post
Share on other sites
No need to double-post about the filename / data type question; you've been warned.

As for the description field, sounds like you have special characters, usually from a cut-and-paste operation from a rich-text editor.  You need to strip all of these, convert them somehow, or encode them.

Share this post


Link to post
Share on other sites
Well a file path is just plain text, so I would use a VARCHAR. If you are using MySQL 5, then have a look [url=http://dev.mysql.com/doc/refman/5.0/en/data-types.html]here[/url] for a reference to the respective data types.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.