Page 1 of 1

Image is going into directory but not database

Posted: Mon Nov 10, 2008 11:13 am
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

Re: Image is going into directory but not database

Posted: Mon Nov 10, 2008 11:26 am
by aceconcepts

Code: Select all

$bg_image = $_POST['bg_image']['name'];
Take a look at: http://uk2.php.net/features.file-upload

Re: Image is going into directory but not database

Posted: Mon Nov 10, 2008 11:31 am
by rooomka
Worked like a champ! Thank you!