FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


php download system prob





riyadh
i wrote a download system in php so tht i can liink my downloads like
Quote:
http://www.mysite.net/download.php?file=2
. when i type this in the browser's address bar, nothing is returned. the code for the download.php file is:
Code:

<?php
include('config_downloads.php');

if (isset($file)){

   dbConnect();
   $sql = "select address from downloads";
   $result = mysql_query($sql);
   $rows = mysql_num_rows($result);
   
   for ($x=0;$x<$rows;$x++) {
   $urlarray[$x] = mysql_result($result,$x);
   }
   
   $request = $urlarray[$file];
   
   if (!$request) {
      echo ("Error on url string");
   }
   else {
      header("Location: $request");
   }
   
   $query = "UPDATE downloads SET downloads=downloads+1 WHERE id = $file";
   $result = mysql_query($query);
   if (!$result){
      echo("Database Error");
   }
   $datetime = date('d M Y h:i:s a');
   $querystat = "INSERT INTO stats SET ID='$file', IP='$REMOTE_ADDR', Date/Time='$datetime'";
   $resultstat = mysql_query($querystat);
   if (!$result){
      echo("Database Error");   
   }
   
}

if (isset($downloads)){
   dbConnect();
   $query = "SELECT downloads FROM downloads WHERE id = $downloads";
   $result = mysql_query($query);
   $hits = mysql_result($result,0);
   echo($hits);
}
?>


where
Quote:
address
is the real address of the files,
Quote:
id
is the id of the files etc.[/quote]
shamil
You should use
Code:
isset($_GET['file'])
instead
Code:
isset($file)

Codes after the
Code:
   if (!$request) {
      echo ("Error on url string");
   }
   else {
      header("Location: $request");
   }

dont get executed unless there is error. I think you didin't wish to do that. If so precede them before the line
Code:
header("Location: $request");
Related topics
A "small" list of free apps
Simple PHP Navigation
Adding PHP to My HTML site
Latest PHP install may cause phpBB to return errors...
PHP Blog
Big guide to FREE programs!
Php link system
PHP scripting - system of post and upload
Witch PHP board system is the best?
AJAX and PHP rating system
PHP Member System (using FOPEN)..
Frih$ on offer for PHP Login System
php home system help
Download System Help
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.