cturner Posted October 27, 2006 Share Posted October 27, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/25277-adding-a-filename-to-a-database/ Share on other sites More sharing options...
gmwebs Posted October 28, 2006 Share Posted October 28, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/25277-adding-a-filename-to-a-database/#findComment-115783 Share on other sites More sharing options...
fenway Posted October 28, 2006 Share Posted October 28, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/25277-adding-a-filename-to-a-database/#findComment-115895 Share on other sites More sharing options...
cturner Posted October 28, 2006 Author Share Posted October 28, 2006 What datatype should I use for a file path? Quote Link to comment https://forums.phpfreaks.com/topic/25277-adding-a-filename-to-a-database/#findComment-116046 Share on other sites More sharing options...
gmwebs Posted October 28, 2006 Share Posted October 28, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/25277-adding-a-filename-to-a-database/#findComment-116048 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.