Выводить ошибку смотреть и исправлять. Вообще я бы не так написал. И пора забывать про mysql_* функции.
Код:
<?php
$db = mysql_connect ("localhost","name","pass");
mysql_select_db("name_bd", $db);
mysql_query( 'SET NAMES utf8' );
echo processDownload($_GET["type"]);
function processDownload($linkType)
{
switch($linkType)
{
case 'torrent':
$file = 'http://site.com/file.torrent';
break;
case 'site':
$file = 'http://download.cs-mastery.ru/Counter%20strike_1.6_vp_%202.0.13_a.rar';
break;
case 'yandex':
$file = 'http://yadi.sk/d/L7VFWwPQHPMdc';
break;
default:
return FALSE;
}
$result = mysql_query("INSERT INTO `linker` (`cons`,`type`) VALUES ('1','{$linkType}')");
if($result) {
header("Content-Disposition: attachment; filename='" . basename($file) . "';");
return file_get_contents($file);
}
return FALSE;
}
Отредактировал: onotole, - 16.2.2014, 7:22