can't download file from database, got error, help me please..

<?php
require("conn2.php");
$sql="select image from images where id='$_GET[id]';";
$result = mysql_query($sql);
$row = mysql_fetch_array($result)

$name = $row['image']; // the name of the file that is downloaded
$FilePath = "upload"; // the folder of the file that is downloaded , you can put the file in a folder on the server just for more order

$size = filesize($FilePath . $name) ;
header("Content-Type: application/force-download; name=\"". $name ."\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ". $size ."");
header("Content-Disposition: attachment; filename=\"". $name ."\"");
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
echo (readfile($FilePath . $name));
?>

$sql="select image from images where id='$_GET[id]';";

I think you should remove the first semicolon in that line and place it after the following line:

$row = mysql_fetch_array($result)

Next question: What is the error you are getting? :)

Also, if you are using PHP's mysql functions to connect to your database, you might want to consider properly escaping external input to your database, like $_GET['id']. I would replace that by mysql_real_escape_string($_GET['id']) for starters. You can read more about the function here.

Parse error: syntax error, unexpected '$name' (T_VARIABLE) in C:\xampp\htdocs\form\admin2\download.php on line 10

Yes that's probably, as I just mentioned, because you don't close your line 9 with a semicolon (";"). Try removing the semicolon from inside your quotes in the following line:
$sql="select image from images where id='$_GET[id]';";

Which would make it become:
$sql="select image from images where id='$_GET[id]'";

Then add the mysql_real_escape_string() functionality, like this:
$sql="select image from images where id='" . mysql_real_escape_string($_GET[id]) . "'";

And then place a semicolon at the end of the following line:
$row = mysql_fetch_array($result)

Which would make it become:
$row = mysql_fetch_array($result);

hahahaha.. yes u r right..

Glad to see your problem solved ^^.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.