![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Programmer
Join Date: Sep 2005
Location: PA, USA
Posts: 49
Rep Power: 0
![]() |
variable in url
I'm trying to incorporate a secure download script into an already coded file management system. I want the url path to be download.php?file=, and then the file name. The file name is taken from the variable .$file. How do I add the variable onto the end of the url? What I currently have below doesn't seem to work. It passed the error:
Quote:
__________________
"I have many layer-eight problems in my life, including myself." |
|
|
|
|
|
|
#2 |
|
Programmer
Join Date: Jan 2005
Posts: 44
Rep Power: 0
![]() |
Your causing php to think your finished with the string when you use the double quotes (") for the href=",
so this [PHP]$file_string = "<li>Get file: <a href="download.php?file=.$file."> ".$file."</a> (".human_file_size(filesize($file)).")</li>";[/PHP] should be this [PHP] $file_string = '<li>Get file: <a href="download.php?file='.$file.'"> "'.$file.'"</a> ("'.human_file_size(filesize($file)).'")</li>';[/PHP] hope it helps Magic E |
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
You can also use the backslash to "escape" the quotes:
[php]$file_string = "<li>Get file: <a href=\"download.php?file=$file\">$file</a> (" . human_file_size(filesize($file)) . ")</li>"; $file_string = '<li>Get file: <a href="download.php?file=' . $file . '"> "' . $file . '"</a> ("' . human_file_size(filesize($file)) . '")</li>';[/php] |
|
|
|
|
|
#4 | |
|
Professional Programmer
|
Quote:
|
|
|
|
|
|
|
#5 | |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#6 | |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Quote:
But I don't use PHP, i just saw an opportunity to increase my post count. ![]() |
|
|
|
|
|
|
#7 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
I prefer using single quotes myself. Because strings in single quotes aren't checked for variable names, they work faster.
|
|
|
|
|
|
#8 | |
|
Professional Programmer
|
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|