Jump to content

Update problem


scmeeker

Recommended Posts

(I've shortened the code a bit for viewing)

 

Okay, I got the other part I posted previously working.  Now once the user is satisfied with addind/updating their details they move on to a new page where they will upload an image.  I'm able to upload the image just fine but I'm trying to get the file name of the image to be inserted into the associated product record in the table.  When I click it, it returns my image to the browser (good) and uploads it (good) but does not put the name in the product record.

 

Here is the form action code for this page:

 

<?php session_start (); ?>
<?php ini_set("memory_limit", "200000000"); // for large images so that we do not get "Allowed memory exhausted"?>
<?php

mysql_connect("localhost", "root", "", "sgallery") or die(mysql_error());

mysql_select_db("sgallery") or die(mysql_error());

$item_image = $_FILES['image_upload_box']['name'];
$item_id =  mysql_real_escape_string($_POST[id]);
  
$sql="UPDATE product SET image_upload_box='$item_image' WHERE id = '$item_id'";

if (!mysql_query($sql))

  {

  die('Error: ' . mysql_error());

  } 
else {

header("Location: add_new_product4.php?id={$item_id}=success&show_image=".$_FILES["image_upload_box"]["name"]);
	exit;
}
else{
	header("Location: add_new_product.php4?upload_message=make sure the file is jpg, gif or png and that is smaller than 4MB&upload_message_type=error");
	exit;
}
}
}
?>

 

It's also not holding the $item_id in the URL code from above:

 

header("Location: add_new_product4.php?id={$item_id}=success&show_image=".$_FILES["image_upload_box"]["name"]);

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.