> Why does this code produce a page cannot be displayed error?
Your query is probably wrong. Comment out the header stuff and add some
error checking to your query.
> <?php
> mysql_connect("localhost","username","password");
> mysql_select_db("database");
> $query = "SELECT file_path from photos where photos_id=$photos_id";
> $result = @mysql_query("$query");
The quotes are useless there. Change the above to:
$result = mysql_query($query) or die(mysql_error());
> $row = mysql_fetch_row($result);
> $path = $row[0];
> $parts = split("/",$path);
Use explode() instead. No sense wasting a regex on a trivial delimiter
like that.
> $file_name = $parts[count($parts)-1];
uh.. basename() would do the same thing, so you can get rid of this line
and also the split/explode actually.
> header("Content-Type: application/download\n");
> header("Content-Disposition: attachment; filename=$file_name");
> header("Content-Transfer-Encoding: binary");
> $fn=fopen($path , "r");
> fpassthru($fn);
readfile($path); would replace those two lines.
-Rasmus
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]