problem with $_GET
Posted: Mon Jun 30, 2008 5:10 pm
For future reference, please enclose code in your posting, using [ code] and [ /code] tags, as I have done below for you. Thank you.
Moderator
i am trying to add an image source to my database, but it wont let me get the product_id with $_GET with this in my code it doesnt even make it to the data base i will show all code connected
this is the form that takes the information
after it is sent it goes to this site and i am pretty sure this is where the error is but not positive
any help is greatly appreciated i feel like i have tried everything
Moderator
i am trying to add an image source to my database, but it wont let me get the product_id with $_GET with this in my code it doesnt even make it to the data base i will show all code connected
this is the form that takes the information
Code: Select all
<form enctype="multipart/form-data" action="uploader.php?prod=<?php echo urlencode($sel_product['product_id']); ?>" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" value= "<?php if(isset($sel_product['image_source'])){echo $sel_product['image_source'];} ?>"/>
<input type="submit" value="Upload File" />
</form>Code: Select all
<?php require_once("includes/session.php"); ?>
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php confirm_logged_in(); ?>
<?php
echo "<pre>";
print_r($_FILES);
echo "</pre>";
$target_path = "C:\wamp\www\site\images".$_FILES['uploadedfile']['name'];
move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path);
$image_source = mysql_prep($target_path);
?>
<?php
$id = $_GET['prod']; //<--------- with this it doesnt even make it to the database just displays an array with my values
$query = "INSERT INTO products (
image_source
) VALUES (
'$image_source'
WHERE product_id = {$id})";
$result = mysql_query($query);
if (mysql_affected_rows() == 1) {
// Success
$message = "The product was successfully updated.";
redirect_to("edit_product.php");
} else {
// Failed
$message = "The product update failed.";
$message .= "<br />". mysql_error();
}?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>