Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 16th, 2006, 10:38 PM   #1
Obtruse_Man4
Programmer
 
Obtruse_Man4's Avatar
 
Join Date: Sep 2005
Location: PA, USA
Posts: 49
Rep Power: 0 Obtruse_Man4 is on a distinguished road
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:
Parse error: parse error, unexpected T_STRING in /home/.anabel/mecabe/farsideofthegalaxy.com/downloads/codebase.inc.php on line 57
[PHP]$file_string = "<li>Get file: <a href="download.php?file=.$file."> ".$file."</a> (".human_file_size(filesize($file)).")</li>";[/PHP]
__________________
"I have many layer-eight problems in my life, including myself."
Obtruse_Man4 is offline   Reply With Quote
Old Jan 17th, 2006, 5:35 AM   #2
magic_e
Programmer
 
Join Date: Jan 2005
Posts: 44
Rep Power: 0 magic_e is on a distinguished road
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
magic_e is offline   Reply With Quote
Old Jan 17th, 2006, 6:12 AM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
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]
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jan 17th, 2006, 11:02 AM   #4
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
Quote:
Originally Posted by Ooble
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]
That's the method I prefer, works for all the characters that PHP might interpret wrong
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Old Jan 17th, 2006, 12:31 PM   #5
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
Quote:
Originally Posted by Lich
That's the method I prefer, works for all the characters that PHP might interpret wrong
Same for me
Polyphemus_ is offline   Reply With Quote
Old Jan 17th, 2006, 2:19 PM   #6
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
Quote:
Originally Posted by Polyphemus_
Same for me
And me.

But I don't use PHP, i just saw an opportunity to increase my post count.
OpenLoop is offline   Reply With Quote
Old Jan 17th, 2006, 3:09 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
I prefer using single quotes myself. Because strings in single quotes aren't checked for variable names, they work faster.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jan 18th, 2006, 12:14 AM   #8
Lich
Professional Programmer
 
Lich's Avatar
 
Join Date: May 2005
Location: Detroit
Posts: 254
Rep Power: 4 Lich is on a distinguished road
Send a message via AIM to Lich Send a message via MSN to Lich
Quote:
Originally Posted by Ooble
I prefer using single quotes myself. Because strings in single quotes aren't checked for variable names, they work faster.
In some cases it's alright to use, I just have the \ habit from unix and whatnot, so I stick with it
__________________
--John Cruz
Web Developer
www.cruzweb.net
Lich is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:58 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC