Page 1 of 1

Forward slash, slash conversion, browser compatibility etc..

Posted: Tue Sep 01, 2009 7:07 pm
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)

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

Posted: Tue Sep 01, 2009 7:24 pm
by Benjamin
:arrow: Moved to PHP - Code

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

Posted: Tue Sep 01, 2009 7:49 pm
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.

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

Posted: Tue Sep 01, 2009 8:16 pm
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...