piznac Posted August 28, 2006 Share Posted August 28, 2006 I have a long script that I have asked questions about in another post. I have everything working except the last portion. I have a form with 10 file fields,.. I have called these as an array. When I try to put the path name in the database I get some wierd results. Please let me know what Im doing wrong:[quote]foreach ($_FILES['file']['name'] as $value3) {$pathname .= "$path$value3";$thumbpath .= "$path2$value3";$mysql = "rack_pm";mysql_select_db($mysql);$sql = "INSERT INTO `returnedfiles` (`imagepath`, `thumbpath`, `jobnum`, `pname`, `num`, `autojobnum`) VALUES ('$pathname', '$thumbpath', '000', 'nada', NULL, '1');";mysql_query($sql) or die('Error, insert query failed');}echo $pathname;echo $thumbpath;[/quote]the results Im getting with the database and the echo are:[quote]$pathname = http://project.rackattackzone.com/jobs/Nike/return_images/IMAG0011.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/IMAG0011.JPGIMAG0006.JPGthumbpath = http://project.rackattackzone.com/jobs/Nike/return_images/thumbs/IMAG0011.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/thumbs/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/thumbs/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/thumbs/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/thumbs/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/thumbs/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/thumbs/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/thumbs/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/thumbs/IMAG0011.JPGIMAG0006.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/thumbs/IMAG0011.JPGIMAG0006.JPG[/quote]as you can see Im getting tons of records I dont need,.. any help would be great At this point only two fo the ten file fields have been used,.. so I should only get two results Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 28, 2006 Share Posted August 28, 2006 [code]$mysql = "rack_pm";mysql_select_db($mysql);foreach ($_FILES as $value) { $pathname .= $path . $value['name']; $thumbpath .= $path2 . $value['name']; $sql = "INSERT INTO `returnedfiles` (`imagepath`, `thumbpath`, `jobnum`, `pname`, `num`, `autojobnum`) VALUES ('$pathname', '$thumbpath', '000', 'nada', NULL, '1')"; mysql_query($sql) or die(mysql_error()); echo $pathname . "<br>"; echo $thumbpath . "<br><br>";}[/code] Quote Link to comment Share on other sites More sharing options...
piznac Posted August 28, 2006 Author Share Posted August 28, 2006 ok that did change it butthe first entry was right,.. but the 2nd returned this:http://project.rackattackzone.com/jobs/Nike/return_images/IMAG0011.JPGhttp://project.rackattackzone.com/jobs/Nike/return_images/IMAG0006.JPGit keeps combining them Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 28, 2006 Share Posted August 28, 2006 change:[code]$pathname .= $path . $value['name'];$thumbpath .= $path2 . $value['name'];[/code]to:[code]$pathname = $path . $value['name'];$thumbpath = $path2 . $value['name'];[/code]Notice it's no longer using the ".=" (concatenation) operator. Quote Link to comment Share on other sites More sharing options...
piznac Posted August 28, 2006 Author Share Posted August 28, 2006 ahhh yes,.. thanks man ;D 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.