allow user to add image to a product they post
Posted: Wed Mar 18, 2009 9:15 pm
hello,
i'm not exactly sure if my problem is with php or my database, but i'm pretty sure it all starts with the database for this one. right now i have allow users to post a new product they can sell, similar to someone making a post on craigslist for example. however, i do not currently allow users to add an image of their product, which brings me here... i have read that it is a better practice to store the images in a separate hash file system, but before i get to figuring that out, i need more of a starting point.
right now i have a postTable which stores the post_id(pk, auto_increment), post_title, product_name, and user_id.
i have just created an imageTable which stores the image_id(pk, auto_increment), imagedata(mediumblob), imagetype, and post_id.
my question: with the insert form on the 'Post New Product' page, how can i have just one form to submit the information into the postTable and also insert the information into the imageTable(only if an image is added)?
my current results leave me with an error message telling me to check my sql syntax on line 1, null, null... i just have it setup like this: $insertsql = insert into postTable (columns...) VALUES (%s....) $result THEN I HAVE $insertsql = insert into imageTable (columns...) VALUES (%s....) $result .
thank you for anyone taking a look and for the help.
i'm not exactly sure if my problem is with php or my database, but i'm pretty sure it all starts with the database for this one. right now i have allow users to post a new product they can sell, similar to someone making a post on craigslist for example. however, i do not currently allow users to add an image of their product, which brings me here... i have read that it is a better practice to store the images in a separate hash file system, but before i get to figuring that out, i need more of a starting point.
right now i have a postTable which stores the post_id(pk, auto_increment), post_title, product_name, and user_id.
i have just created an imageTable which stores the image_id(pk, auto_increment), imagedata(mediumblob), imagetype, and post_id.
my question: with the insert form on the 'Post New Product' page, how can i have just one form to submit the information into the postTable and also insert the information into the imageTable(only if an image is added)?
my current results leave me with an error message telling me to check my sql syntax on line 1, null, null... i just have it setup like this: $insertsql = insert into postTable (columns...) VALUES (%s....) $result THEN I HAVE $insertsql = insert into imageTable (columns...) VALUES (%s....) $result .
thank you for anyone taking a look and for the help.