Forward slash, slash conversion, browser compatibility etc..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kutchbhi
Forum Newbie
Posts: 12
Joined: Mon Aug 24, 2009 2:00 pm

Forward slash, slash conversion, browser compatibility etc..

Post by kutchbhi »

Sorry for the vague subject, but I am soo confused right now.

Here is the necessary code -
//Storing the path of an html file

Code: Select all

$newfile = "categories\books\\".$newfile1 ;
fwrite($fp, $title."||".$description."||".$email."||".$newfile."••\n");
//retrieving the path and making a link

Code: Select all

 
echo $data[$k][3] ; // this outputs categories\video\14a9d9f6b13130.html
echo "<tr><td> <a href=".$data[$k][3]." >".$data[$k][0]."</a> </td></tr>"; // making a link
THe problem now is that the link thus formed doesn't works (in opera/firefox), it ends up like -

Code: Select all

http://localhost/categories\books\14a9988973938a.html (note the slash)
instead of being

Code: Select all

http://localhost/categories/books/14a9988973938a.html (note the slash)
The weird part, is that in internet explorer the link magically sets itself right. the slash automatically convert themselves to forward slashes and the link points to the right place .
Even weirder in firefox the slash to forward slash conversion did work a while back. Not sure what affected this

what is happening ?

Help please
I am running the site on netserver (localhost)
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Forward slash, slash conversion, browser compatibility etc..

Post by Benjamin »

:arrow: Moved to PHP - Code
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Forward slash, slash conversion, browser compatibility etc..

Post by requinix »

The real question is why you're using backslashes in the URL.


Anyways, \s aren't supposed to be in there. IE (being a primarily-Windows application) is nice enough to automatically convert \s to /s but the other browsers don't do that. Whether a browser should or not...

So use forward slashes.
kutchbhi
Forum Newbie
Posts: 12
Joined: Mon Aug 24, 2009 2:00 pm

Re: Forward slash, slash conversion, browser compatibility etc..

Post by kutchbhi »

Changing to forward slash fixes things! Tha ahhhhhh
The real question is why you're using backslashes in the URL.
well I thought it was natural. I didn't expect slash to work in windows... besides this code was working just fine in all browsers. Only today I made some major changes (none of which directly relate to this), that screwed this up...
Post Reply