: PHP code troubleshooting Why PHP code (database + external link) cannot be downloaded?
Source code dl_func.php
-------------------------------------------------------
Function dl_dbconnect (){
$ Dl_in = 0;
// Open the MySQL server connection
$ Dl_in = mysql_connect ("localhost: 3306", "a1006191543", "correct password ");
// Select a database
Mysql_select_db ("a1006191543", $ dl_in );
Return $ dl_in;
}
?>
-------------------------------------------------------
Source code filedown. php
-------------------------------------------------------
Require_once ("dl_func.php ");
$ Dl_in = dl_dbconnect ();
$ StrQuery = "select url from dl_file where id = '$ ID'"; // define query rules
$ Dl_res = mysql_query ($ strQuery, $ dl_in); // The Returned id is sent to $ dl_res.
$ Arrfile = mysql_fetch_array ($ dl_res); // returns an array to $ arrfile based on the id.
$ Arr_temp = split ("/", $ arrfile [url]); // separate strings according to specified rules
$ Filename = $ arr_temp [sizeof ($ arr_temp)-1]; // sizeof: obtains the array size.
$ StrQuery = "update dl_file set count = count + 1 where id = '$ ID '";
Mysql_query ($ strQuery, $ dl_in );
Header ("Content-type: application/file ");
Header ("Content-Disposition: attachment; filename = $ filename ");
Header ("location: $ arrfile [url]");
Mysql_close ($ dl_in );
?>
-------------------------------------------------------
Database Table "dl_file" structure:
Create table dl_file (
Id varchar (6 ),
Name varchar (50 ),
Url varchar (200 ),
Count bigint (10)
);
Id name url count
-------------------------------------------------------
A00stellax http://www.last.com/stella.RAR 0
A002 http://www.mey.com/Z26.ZIP 0
Air combat http://www.piogame.com/River.bin A003 0
B012 skateboard http://www.computer.com/Skate.bin 0
B013 blue genie http://www.computer.com/Catle.bin 0
D064 Snoopy http://www.AKuter.com/Snoopy.bin 0
Previously, the instance runs normally in the purchased space.
In the current space, why are these two programs (with the database username and password changed) reported with an error?
Call method: http: // www. ******. com/filedown. php? Id = A001
IE error message:
"This error (HTTP 403 Forbidden) means Internet Explorer can connect to this website, but does not have the permission to view this webpage ."
Reply to discussion (solution)
Comment out the header first. Echo url to see if it is correct
Fault point found: filedown. php
$ StrQuery = "select url from dl_file where id = '$ ID'"; // define query rules
After changing to a fixed parameter:
$ StrQuery = "select url from dl_file where id = 'a001'"; // define query rules
External link normal
However, how can I change the value of the parameter to true? The call with parameters is as follows:
Http: // www. *****. com/down/filedown. php? Id = A001
$ Id = isset ($ _ GET ['id'])? $ _ GET ['id']: 'a001 ';
$ StrQuery = "select url from dl_file where id = '$ ID '";
If $ id is empty, you have not processed it.
If (! $ Id ){
Exit ();
}