NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page New to PHP - and don't get this....

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 11-09-2005, 03:50 AM THREAD STARTER               #1 (permalink)
New Member
Join Date: May 2005
Posts: 3
royove is an unknown quantity at this point
 



New to PHP - and don't get this....




I'm going to make a page where i register documents and then lists them on a page to easy access.

I use a form (<input type="FILE"....) to register the document and into the database (MySql) it looks fine. (I:\IT\Brukerbeskrivelser\passord.doc)

Then when i'm going to show this on a page and make a link, the link looks like: I://IT//Brukerbeskrivelser//passord.doc - and this will ofcource not work.

Does anyone know what I have not learned in PHP yet... Why do i get the extra "/"? and how does i get rid of it?

Hope someone have a easy answer to this.. and if this is basic in the world of PHP, i'm sorry i asked...
royove is offline  
Old 11-09-2005, 05:03 AM   #2 (permalink)
NamePros Regular
 
NuPagady's Avatar
Join Date: Jul 2005
Posts: 483
NuPagady is on a distinguished road
 



Well I have no idea why you're getting double slash, but if you need a fast solution, you can use str_replace function to get rid of it:

$link = str_replace("//", "/", $link);

It should replace your "//" to "/".
NuPagady is offline  
Old 11-09-2005, 06:52 AM   #3 (permalink)
NamePros Regular
 
moondog's Avatar
Join Date: Jun 2004
Posts: 563
moondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to all
 



You are getting the double slashes because the magic_quotes() setting is ON. Basically, what this does is escape special characters in any form field.

All you need to do is call stripslashes() on the field name.

For example, if you have this:

<input type=file name=fn>

Then in your PHP code, do this:

$_POST[fn] = stripslashes($_POST[fn]);

That SHOULD eliminate the extra slashes.

-Bob
__________________
Want a way to monitor your website against hacking? Check out CrossCheck.net
moondog is offline  
Old 11-09-2005, 07:12 AM THREAD STARTER               #4 (permalink)
New Member
Join Date: May 2005
Posts: 3
royove is an unknown quantity at this point
 



Thanks! This was the solution of my problem!

Should i keep the magic_quotes_gpc setting in php.ini ON, or could i set it OFF without major problems elsewhere?

RoH

Originally Posted by moondog
You are getting the double slashes because the magic_quotes() setting is ON. Basically, what this does is escape special characters in any form field.
????: NamePros.com http://www.namepros.com/programming/138718-new-to-php-and-dont-get.html

All you need to do is call stripslashes() on the field name.

For example, if you have this:

<input type=file name=fn>

Then in your PHP code, do this:

$_POST[fn] = stripslashes($_POST[fn]);

That SHOULD eliminate the extra slashes.

-Bob
royove is offline  
Old 11-09-2005, 07:59 AM   #5 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,074
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
that really depends on your coding and wether you sanitize any input.
Peter is offline  
Old 11-09-2005, 08:05 AM THREAD STARTER               #6 (permalink)
New Member
Join Date: May 2005
Posts: 3
royove is an unknown quantity at this point
 



Thanks - i guess i need a bit more experience before i makes any changes in the php.ini file then :-)
royove is offline  
Old 11-09-2005, 08:47 AM   #7 (permalink)
Domains my Dominion
 
sdsinc's Avatar
Join Date: Aug 2005
Location: Web 1.0
Posts: 9,963
sdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatnesssdsinc Has achieved greatness
 


Third World Education Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Find Marrow Donors! Animal Rescue Animal Cruelty AIDS/HIV Animal Rescue Wildlife Breast Cancer Animal Rescue Wildlife
Magic quotes are the bane of PHP.
It is highly recommended not to depend on those settings.
If you port your script to another server they may not work anymore or misbehave.

Always stripslash whenever needed.
__________________
NameNewsletter.com - free lists of available domain names
ZoneFiles.net (beta) - ccTLD and gTLD droplists
sdsinc is online now  
Closed Thread


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


 
All times are GMT -7. The time now is 02:03 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger