I have the following code where I read information submitted by a form.
<?php
$i = 1;
while($i <= 15){
if($_POST['image_id' . $i] > 0)
{
$im_update_sql = "UPDATE product_images SET products_image_name = $_POST['file' . $i] , products_image_sort = $_POST['sort' . $i], products_image_desc = $_POST['desc' . $i] where products_image_pid = $_POST['image_id' . $i]";
mysql_query($im_update_sql);
echo "Update ";
}
else
{
if(($_POST['sort' . $i] != '') AND ($_POST['file' . $i] != '')){
$im_insert_sql = "INSERT INTO product_images (products_image_id, products_image_pid, products_image_name, products_image_sort, products_image_desc) values ('', $_POST['current_product_id'], $_POST['file' .$i], $_POST['sort' .$i], $_POST['desc' .$i])";
mysql_query($im_insert_sql);
echo "Insert ";
}
else{
echo "Not Inserting ";
}
}
echo 'Image ' . $i . ': ';
echo $_POST['sort' . $i] . ' - ';
echo $_POST['file' . $i] . ' - ';
echo $_POST['desc' . $i] . '<br>';
$i++;
}
?>
I am having a problem with the SQL statements. If I comment them out and the mysql_query() out, I get the following info echoed. So I know I am getting the info.
Update Image 1: 1 - 01.004.jpg - Black
Update Image 2: 2 - 01.004-1.jpg - Blue
Update Image 3: 3 - 01.004-2.jpg - Green
Update Image 4: 4 - 01.004-3.jpg - Ivory
Update Image 5: 5 - 01.004-4.jpg - Yellow
Update Image 6: 6 - 01.004-5.jpg - Orange
Update Image 7: 7 - 01.117-6.jpg - Red
Not Inserting Image 8: - -
Not Inserting Image 9: - -
Not Inserting Image 10: - -
Not Inserting Image 11: - -
Not Inserting Image 12: - -
Not Inserting Image 13: - -
Not Inserting Image 14: - -
Not Inserting Image 15: - -