Jump to content

For Each Insert Into Problem


piznac

Recommended Posts

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.JPG


thumbpath = 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
Link to comment
Share on other sites

[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]
Link to comment
Share on other sites

ok that did change it but

the 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.JPG

it keeps combining them
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.