Many days ago, I have read this question. Then, I have tried with this code:
$code = $_GET['code'];
$str_1 = mysql_query("SELECT * FROM `MyTable`");
while ($str_2 = mysql_fetch_array($str_1)) {
header("content-type: application/octet-stream");
header("content-disposition: inline; filename= " . $str_2['my_id'] . "");
echo base64_decode($str_2['my_str']);
}
My my data base, there are some data:
+--------+-----------------+
| my_id | my_str |
+--------+-----------------+
| id_1 | base64_str_1 |
| id_2 | base64_str_2 |
| id_3 | base64_str_3 |
| id_4 | base64_str_4 |
+--------+-----------------+
When I browse my PHP code with browser, such as: http://localhost/my_php.php?code=id_3
. It always returns a file (named: id_3
) which is contented (it's content: base64_str_1
).
Can you tell me: "What is wrong in this PHP code, with SQL query?".