home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2035
Discussions: 188,393, Posts: 2,243,573, Members: 232,623
Old February 29th, 2004, 07:55 PM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Apr 2003
Posts: 13
Send a message via AIM to maotx Send a message via Yahoo to maotx
Simple PHP problem

Im currently running a site that accepts file names as variables. Some file names have quotes in them, i.e. 1990's archive.txt
These quotes are messing with my php coding.
How can I retain the variables value without removing the quotes and not have php return an error?
Thanks

maotx is offline   Reply With Quote
Old March 1st, 2004, 08:34 AM     #2 (permalink)
Registered User
 
Join Date: Oct 2001
Posts: 4,097
Not sure how you could do this without serious changes to the code.

Do you have a link and maybe a test account to your site?

ClubMed is offline   Reply With Quote
Old March 1st, 2004, 05:40 PM     #3 (permalink)
Junior Member
 
Join Date: Apr 2003
Posts: 13
Send a message via AIM to maotx Send a message via Yahoo to maotx
Heres the code for the deletion of the file, it is passed as a variable from the browser:

$delete = $_GET['delete'];
$directory = "/home/mao/input/files";
$handle = opendir($directory);
if(isset($delete))
{
while(!unlink("$directory/$delete"));
}
closedir($handle);

And to restate problem for clarity, if $delete variable has a ' in it then the php, of course, dumps an error. And seeing how the variable name has to stay the same to delete the file, I need a different solution. The link in which this php is being used has sensitive information...I might be able to create a dumby if it is needed though.

maotx is offline   Reply With Quote
Old March 1st, 2004, 05:48 PM     #4 (permalink)
Real gangstas sip on Yacc
 
jkrohn's Avatar
 
Join Date: Oct 2001
Location: Suckas-ville
Posts: 4,549
Send a message via ICQ to jkrohn Send a message via AIM to jkrohn Send a message via Yahoo to jkrohn
You really should turn on Magicquotes. This will automaticly escape and quote characters and is a very good idea to prevent against code injection.

Aside from that, running addslashes() on the variable first will escape any quotes located in the variable.

addslashes()
http://us2.php.net/addslashes
and
stripslashes()
http://us2.php.net/manual/en/function.stripslashes.php

Jkrohn
__________________
Signatures blow hard
If your signature contains an ad of any kind, congratulations, you're on my ignore list.
jkrohn is offline   Reply With Quote
Old March 1st, 2004, 06:55 PM     #5 (permalink)
Junior Member
 
Join Date: Apr 2003
Posts: 13
Send a message via AIM to maotx Send a message via Yahoo to maotx
Thanks, addslashes works for what i need
maotx is offline   Reply With Quote
Reply


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

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2904)
Building a gaming computer advice (5)
New Build ( Finally ) (6)
Looks like Burris will get his Sena.. (12)
CPU wont boot (7)
3-days in and no threads about Gaza (160)
I think I just killed my computer w.. (24)
Folderchat Weekday thread (444)
Upgrading RAM (6)
Recent Discussions
Iming and surfing slowed down (3)
Laptop proccesor to desktop mob.. (0)
Please help! multiple problems! (3)
Left 4 Dead Small Freezes (1)
Install Problem for Windows Def.. (1)
RCA 52Inch HDTV wont turn on (2)
nVidia GTX 295 now available (1)
Error ~ BAD BLOCK (19)
I think my PSU is dieing (0)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 01:48 AM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28