Image is going into directory but not database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rooomka
Forum Newbie
Posts: 7
Joined: Mon Nov 10, 2008 11:07 am

Image is going into directory but not database

Post by rooomka »

I have been troubleshooting all day and have run into a brick wall. I have done this time and time again, but for whatever reason, my code is NOT working....or my head is not working. Lol. I am trying to insert an image into a MySQL database, but it IS NOT GOING INTO THE FREAKIN’ DATABASE….however it is going in the directory(the "images/bgimages/" folder). Every statement seems to be fine…the field is called “bg_image”. I must be missing something, so I was hoping a fresh pair of eyes may help. Below is the code for the image insertion field, where I declare the variable, and where I insert it in the database. HELP!

<input name="bg_image" type="file" class="form" id="bg_image" size="60">

$bg_image = $_POST['bg_image'];

mysql_query("INSERT INTO hex SET custom_name = '$custom_name', body_bg = '$body_bg', bg_image = '$bg_image', bgrepeat = '$bgrepeat', bgshow = '$bgshow', body_text = '$body_text'…….

Thanks...
Rooomka
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Image is going into directory but not database

Post by aceconcepts »

Code: Select all

$bg_image = $_POST['bg_image']['name'];
Take a look at: http://uk2.php.net/features.file-upload
rooomka
Forum Newbie
Posts: 7
Joined: Mon Nov 10, 2008 11:07 am

Re: Image is going into directory but not database

Post by rooomka »

Worked like a champ! Thank you!
Post Reply