Jump to content

Upload image, Make Thumb, Post both paths to db


djjon5

Recommended Posts

Im am about 5 days into PHP and have learned the basics. But i am still getting stuck on some things.

 

I am looking to have a form where i can add item information and at the bottom of the form there will be a field for a image upload.

 

I already have the script running (and working) that will upload the image, thumbnail it and store it in a directory. Now i am looking to post the paths for both the image & the thumb to two seperate fields in my database.

 

I would like all of this to be done and only have one image field showing in the form.

 

I am useing dreamweaver CS3 if there may be a quicker way of accomplishing this with DW. But i am trying to learn PHP so i would rather script it myself.

 

If anyone can help, it would be awsome. Thanks in advance

Link to comment
Share on other sites

I just need to know how to take the image path that the script gave the image and thumbnail and post it to the database.

 

I assume i can just add some code to the script i already have to do this. I dont really know the codeing yet

 

Sorry if i am a little confusing, this is my first forum post ever.

Link to comment
Share on other sites

Yes you could add some code, but it depends on what type of database you are using. Is the code already accessing that database? If it is, all you need is an SQL statement like:

"INSERT INTO table (ImageLink, ThumbLink) VALUES ('$imglink', '$thumblink')"

 

Is that what you are looking for?

Link to comment
Share on other sites

Ok, You will want to use the mysql_query function, then.

$qry = mysql_query("INSERT INTO table (ImageLink, ThumbLink) VALUES ('$imglink', '$thumblink')") or die(mysql_error());

 

And you access it, use mysql_fetch_assoc (or mysql_fetch_array)

$firstrow = mysql_fetch_assoc($qry);

 

Here is the documentation for PHP mysql functions: http://www.php.net/manual/en/ref.mysql.php

 

Good luck!

Link to comment
Share on other sites

i used the script you gave me and now i get this error under my image file form field.

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table (prodImage1, thumbPath) VALUES ('../images/' . '', '../images/thumbs/' . '' at line 1

 

this is the page: http://www.j5industries.net/ehwms/onlinestore/admin/add_product.php

Link to comment
Share on other sites

I'm going to go out on a limb here and guess that your images are always stored in images/ and the thumbnails are always stored in images/thumbs/.

 

If that is the case then I pose a hypothetical question for you:

If the directories where the images are stored are always the same and known in advance, why bother storing them in the database at all?

 

*hint* You could probably get by with storing just the filename. *hint*

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.