dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: Need Help inserting / retrieving images from MySQL Database

  1. #1
    Join Date
    Apr 2013
    Posts
    23

    Need Help inserting / retrieving images from MySQL Database

    Good morning programmers,

    How do you insert an image name into a MySQL database?

    For example - car.jpeg, bike.png

    What is the code for storing a name with a decimal (.) in it?

    Do I use blob, longblob, varchar?

    Any suggestions would be great

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,614
    It's just text, so varchar should be fine.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Apr 2013
    Posts
    23

    Still not working

    Thanks for the reply but I'm still stuck.

    What I'm actually trying to do is retrieve the images from $_FILES, put in my current directory, store it in a variable, then send the code to the MySQL database.

    How do you insert a variable into the database? Something like $img?

    Any suggestions would be great.

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,614
    Best way is to use the MySQLi or PDO DB extension, and make use of prepared statements in conjunction with bound parameters. (The bind-param part is where you'd get the variable value injected into the DB query.)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles