RCS Posted April 15, 2008 Share Posted April 15, 2008 ok if I want to use the script below how would I INSERT array info into a database Thanks in advance <?php $imagedir = "x"; if (isset($_POST['btnSub'])) { $desc = $_POST['desc']; $price = $_POST['price']; $make = $_POST['make']; foreach ($_FILES['picfile']['name'] as $k => $name) { $tmpname = $_FILES['picfile']['tmp_name'][$k]; $type = $_FILES['picfile']['type'][$k]; // process each pic here } // update db here } ?> <form method='post' enctype='multipart/form-data'> <?php echo "Make <input type='text' name='make[]' /><br/>"; echo "Description <input type='text' name='desc[]' size='60' /><br/>"; echo "Price <input type='text' name='price[]' /><br/>"; for ($i=1; $i<=10; $i++) { echo "<fieldset>\n"; echo "<legend>Picture $i</legend>\n"; echo "<input type='file' name='picfile[]' size='60' /><br/>"; echo "</fieldset><br/>\n"; } ?> <input type='submit' name='btnSub' value='Submit'> </form> Then tried something like this to connect and INSERT but it did not work. $query = "INSERT INTO upload(id, name, TYPE, size, content, make, description, price, name2, type2, size2, content2, name3, type3, size3, content3, name4, type4, size4, content4, name5, type5, size5, content5, name6, type6, size6, content6, name7, type7, size7, content7, name8, type8, size8, content8, name9, type9, size9, content9, name10, type10, size10, content10,)". "VALUES ($_POST[id],'$fileName', '$fileType', '$fileSize', '$content','$_POST[make]','$_POST[description]','$_POST[price]','$fileName2', '$fileType2', '$fileSize2', '$content2', '$fileName3', '$fileType3', '$fileSize3', '$content3', '$fileName4', '$fileType4', '$fileSize4', '$content4', '$fileName5', '$fileType5', '$fileSize5', '$content5', '$fileName6', '$fileType6', '$fileSize6', '$content6', '$fileName7', '$fileType7', '$fileSize7', '$content7', '$fileName8', '$fileType8', '$fileSize8', '$content8', '$fileName9', '$fileType9', '$fileSize9', '$content9', '$fileName10', '$fileType10', '$fileSize10', '$content10',)"; Link to comment https://forums.phpfreaks.com/topic/101283-insert-into-and-connection-with-an-array/ Share on other sites More sharing options...
amites Posted April 15, 2008 Share Posted April 15, 2008 get rid of the comma after content10 Link to comment https://forums.phpfreaks.com/topic/101283-insert-into-and-connection-with-an-array/#findComment-518058 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.