English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

$allowed_filetypes = array('.jpg','.gif','.bmp','.png','.pjpeg');
$max_filesize = 524288;
$upload_path = './images/';
$filename = $_FILES['pic']['name'];
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
if(!in_array($ext,$allowed_filetypes))
die('The file type is not allowed.');
if(filesize($_FILES['pic']['tmp_name']) > $max_filesize)
die('The file is too large.');
if(!is_writable($upload_path))
die('You cannot upload to the specified directory.');
if(move_uploaded_file($_FILES['pic']['tmp_name'],$upload_path . $filename))
echo 'Success, view the file here';
else
echo 'There was an error. Please try again.';
$prod = $_GET['id'];
$path = . $upload_path . $filename .
mysql_select_db("products", $con);
mysql_query("INSERT INTO prods SET path='$path' WHERE id='$prod'");
mysql_close

If I leave out the sql query and all of that, the script works fine. But when I add the sql parts, it doesn't. Help?

2007-12-16 02:27:04 · 3 answers · asked by thepoor666 1 in Computers & Internet Programming & Design

I replaced the query and it still doesn't work.

2007-12-16 03:02:22 · update #1

3 answers

Hello

In your code, you tried to update the values in the table with image path.. But your query is incorrect.. Right one is below:

$query = "UPDATE prods SET path='$path' WHERE id='$prod' ";

mysql_query($query );

Welcome to world of PHP...

Regards,
Seban

2007-12-16 02:47:57 · answer #1 · answered by php-developer 1 · 0 0

If the record already exists, you want to use update rather than insert. If you're adding a new record, you want to do something like:

"insert into prods (id, path) values ($prod, '$path')"

If that doesn't help, show us what error(s) your are getting.

2007-12-16 03:11:04 · answer #2 · answered by daa 7 · 0 0

If the checklist already exists, you desire to apply replace fairly than insert. once you're including a sparkling checklist, you desire to do some thing like: "insert into prods (id, direction) values ($prod, '$direction')" If that doesn't help, instruct us what blunders(s) your are transforming into.

2016-10-11 09:49:30 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers