djjon5 Posted December 17, 2007 Share Posted December 17, 2007 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 Quote Link to comment Share on other sites More sharing options...
lemmin Posted December 17, 2007 Share Posted December 17, 2007 It is as simple as updating your database, you have all the hard stuff done. Where is the problem? Do you need help with the db query statement? What kind of database are you using? Quote Link to comment Share on other sites More sharing options...
djjon5 Posted December 17, 2007 Author Share Posted December 17, 2007 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. Quote Link to comment Share on other sites More sharing options...
lemmin Posted December 17, 2007 Share Posted December 17, 2007 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? Quote Link to comment Share on other sites More sharing options...
djjon5 Posted December 17, 2007 Author Share Posted December 17, 2007 yes. That is I will try that Thank you Sorry i forgot to tell you i am using MySQL DB and it is already loaded in the script Quote Link to comment Share on other sites More sharing options...
lemmin Posted December 17, 2007 Share Posted December 17, 2007 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! Quote Link to comment Share on other sites More sharing options...
djjon5 Posted December 18, 2007 Author Share Posted December 18, 2007 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 Quote Link to comment Share on other sites More sharing options...
lemmin Posted December 18, 2007 Share Posted December 18, 2007 "table" needs to be the name of your table in your database that you are inserting the paths into. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted December 18, 2007 Share Posted December 18, 2007 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* Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.