Jump to content


Photo

Adding a filename to a database?


  • Please log in to reply
4 replies to this topic

#1 cturner

cturner
  • Members
  • PipPipPip
  • Advanced Member
  • 148 posts
  • LocationMy computer

Posted 27 October 2006 - 05:33 AM

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: 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. Don?t say you haven?t been warned!

#2 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 28 October 2006 - 11:12 AM

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 addslashes(). I normally use a VARCHAR datatype for filenames - as long as you do mean just the filename, and not the file itself.

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 28 October 2006 - 04:12 PM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#4 cturner

cturner
  • Members
  • PipPipPip
  • Advanced Member
  • 148 posts
  • LocationMy computer

Posted 28 October 2006 - 09:21 PM

What datatype should I use for a file path?

#5 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 28 October 2006 - 09:24 PM

Well a file path is just plain text, so I would use a VARCHAR. If you are using MySQL 5, then have a look here for a reference to the respective data types.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users