path modification problem

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
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

path modification problem

Post by itsmani1 »

here is a page url :

localhost/sitemap.htm

i want to fetch its its html and wanted to display its html at

localhsot/site_edit/open.php

but i don't want to loos my links, and images, i wanted all the image and css should work fine.


Please help me. what happens is : i can't see the image as the path shows something like : localhost/site_edit/images/spacer.gif it should be localhost/images/spacer.gif so that i can see the correct image.

I am doing like this:

Code: Select all

if(isset($_GET['log']))
		{
			$tmp = $_GET['log'];
			$tmp = str_replace("..//","../",$tmp);
			$contents = fopen("../www/$tmp","r");
			
			while (!feof($contents))
			{
				$read = fread($contents,999999);
			}
			
			fclose($contents);
		}
it opens correct file and work fine but i dont 's how the correct paths.
then I tried :

Code: Select all

$read = str_replace("src=\"","src=\"../",$read);
but its not work? please help me

thanks.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

Problem is solved by removing

"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> " from my web pages, now there is one more problem.

i tried

Code: Select all

str_replace("<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">"," ","<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> sdf asdf asdf")
but its not working
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

itsmani1 wrote:Problem is solved by removing

"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> " from my web pages, now there is one more problem.

i tried

Code: Select all

str_replace("<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">"," ","<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> sdf asdf asdf")
but its not working
Hmmm, i wonder why...maybe try escaping your double quotes.

The syntax highlighter kinda gave it away dont ya think!?
Post Reply