473,396 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Change included code

Can I modify code that I have included using

<?php
include("../Index.php");
?>

The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot. I
need to add "../" to the css file reference in Index.php to make it work.

Thanks,
Jon
Apr 19 '07 #1
27 1896
Jon Slaughter wrote:
Can I modify code that I have included using

<?php
include("../Index.php");
?>

The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot. I
need to add "../" to the css file reference in Index.php to make it work.

Thanks,
Jon

Ensure your link is an absolute path relative to your website root.
Then where you include index.php doesn't matter.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #2

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:D5******************************@comcast.com. ..
Jon Slaughter wrote:
>Can I modify code that I have included using

<?php
include("../Index.php");
?>

The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot. I
need to add "../" to the css file reference in Index.php to make it work.

Thanks,
Jon

Ensure your link is an absolute path relative to your website root. Then
where you include index.php doesn't matter.
It would actually be a bit more trouble since any time I want to upload to
the server to test I will have to change the link. Would be easier just to
have php just add "../" to one spot instead manually doing it every time I
upload to the server.
Apr 19 '07 #3
Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:D5******************************@comcast.com. ..
>Jon Slaughter wrote:
>>Can I modify code that I have included using

<?php
include("../Index.php");
?>

The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot. I
need to add "../" to the css file reference in Index.php to make it work.

Thanks,
Jon
Ensure your link is an absolute path relative to your website root. Then
where you include index.php doesn't matter.

It would actually be a bit more trouble since any time I want to upload to
the server to test I will have to change the link. Would be easier just to
have php just add "../" to one spot instead manually doing it every time I
upload to the server.

And why is that? I never have to change links when I upload to my servers.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #4

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Mu******************************@comcast.com. ..
Jon Slaughter wrote:
>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:D5******************************@comcast.com ...
>>Jon Slaughter wrote:
Can I modify code that I have included using

<?php
include("../Index.php");
?>

The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot.
I need to add "../" to the css file reference in Index.php to make it
work.

Thanks,
Jon
Ensure your link is an absolute path relative to your website root. Then
where you include index.php doesn't matter.

It would actually be a bit more trouble since any time I want to upload
to the server to test I will have to change the link. Would be easier
just to have php just add "../" to one spot instead manually doing it
every time I upload to the server.

And why is that? I never have to change links when I upload to my
servers.

Um, because the directory structure differs on my server than my computer?
My server uses public_html to hold html files while my computer doesn't. I
suppose I could go mess with the apache config file and change it though but
it still doesn't solve my problem complete. I still need to inject html
files into containers in the html/php code.

e.g. when I do

<?php include ('SomeFile.php') ?>

I need to also do something like

<?php include ('File2.php') INTO This.DOM.MainDiv ?>

(just psuedocode)

That is, SomeFile contains a html container that I'd like to fill with
another file(Which needs to be arbitrary).

Maybe I'm going about it wrong but I'm simply trying to make a template that
exists on pages of my web site. Because of the design of the template I
cannotjust do something like

<?php include ('SomeFile.php') ?>

dflasdjflalsdflkaslkdjf
and have that texted show up in the right place. I could split the file
into something like

<?php include ('SomeFile1.php') ?>
dflasdjflalsdflkaslkdjf
<?php include ('SomeFile2.php') ?>

and then it would work but just doesn't seem elegant.
(basically SomeFile1.php ends like

<div class="Container">
and Somefile2.php has the final code

</div>
</body>
</html>
I might end up using that though as it seems pretty simple

Thanks,
Jon

Apr 19 '07 #5
Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Mu******************************@comcast.com. ..
>Jon Slaughter wrote:
>>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:D5******************************@comcast.co m...
Jon Slaughter wrote:
Can I modify code that I have included using
>
<?php
include("../Index.php");
?>
>
The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot.
I need to add "../" to the css file reference in Index.php to make it
work.
>
Thanks,
Jon
Ensure your link is an absolute path relative to your website root. Then
where you include index.php doesn't matter.

It would actually be a bit more trouble since any time I want to upload
to the server to test I will have to change the link. Would be easier
just to have php just add "../" to one spot instead manually doing it
every time I upload to the server.
And why is that? I never have to change links when I upload to my
servers.


Um, because the directory structure differs on my server than my computer?
My server uses public_html to hold html files while my computer doesn't. I
suppose I could go mess with the apache config file and change it though but
it still doesn't solve my problem complete. I still need to inject html
files into containers in the html/php code.
So? Mine differs also - my test system is Windows and most of my hosts
are Unix. And my directory here is much different than the one on the
server. I just set up Apache to handle it. Much easier than trying to
screw around with files like you are.
e.g. when I do

<?php include ('SomeFile.php') ?>
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/SomeFile.php'); ?>

Use the features of the language.
I need to also do something like

<?php include ('File2.php') INTO This.DOM.MainDiv ?>
(just psuedocode)

That is, SomeFile contains a html container that I'd like to fill with
another file(Which needs to be arbitrary).
Same thing.

Maybe I'm going about it wrong but I'm simply trying to make a template that
exists on pages of my web site. Because of the design of the template I
cannotjust do something like

<?php include ('SomeFile.php') ?>

dflasdjflalsdflkaslkdjf
and have that texted show up in the right place. I could split the file
into something like

<?php include ('SomeFile1.php') ?>
dflasdjflalsdflkaslkdjf
<?php include ('SomeFile2.php') ?>

and then it would work but just doesn't seem elegant.
(basically SomeFile1.php ends like

<div class="Container">
and Somefile2.php has the final code

</div>
</body>
</html>
I might end up using that though as it seems pretty simple

Thanks,
Jon
Whatever. I just include files where they are needed. Sometimes
they're at the top of the file, sometimes the bottom, and sometimes in
between.

What's more important - something you think looks "elegant", or
something which works and is easy to maintain?


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #6
>>>Index.php is basically an html file uses a linked css file and when its
>>>included in the new file its referencing a css file in the wrong spot.
I need to add "../" to the css file reference in Index.php to make it
work.
If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.

Apr 19 '07 #7

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:yf******************************@comcast.com. ..
Jon Slaughter wrote:
>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Mu******************************@comcast.com ...
>>Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:D5******************************@comcast.c om...
Jon Slaughter wrote:
>Can I modify code that I have included using
>>
><?php
>include("../Index.php");
>?>
>>
>The Index.php file contains links that need to be modified to work.
>Index.php is basically an html file uses a linked css file and when
>its included in the new file its referencing a css file in the wrong
>spot. I need to add "../" to the css file reference in Index.php to
>make it work.
>>
>Thanks,
>Jon
Ensure your link is an absolute path relative to your website root.
Then where you include index.php doesn't matter.
>
It would actually be a bit more trouble since any time I want to upload
to the server to test I will have to change the link. Would be easier
just to have php just add "../" to one spot instead manually doing it
every time I upload to the server.
And why is that? I never have to change links when I upload to my
servers.


Um, because the directory structure differs on my server than my
computer? My server uses public_html to hold html files while my computer
doesn't. I suppose I could go mess with the apache config file and change
it though but it still doesn't solve my problem complete. I still need to
inject html files into containers in the html/php code.

So? Mine differs also - my test system is Windows and most of my hosts
are Unix. And my directory here is much different than the one on the
server. I just set up Apache to handle it. Much easier than trying to
screw around with files like you are.
>e.g. when I do

<?php include ('SomeFile.php') ?>

<?php include ($_SERVER['DOCUMENT_ROOT'] . '/SomeFile.php'); ?>

Use the features of the language.
To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">

But when I include the main file the styles/main.css is referenced from the
directory of that file... but there is not styles/main.css from in that
directory of that file unless it happens to be the root.

Got any more bright ideas?

Apr 19 '07 #8

<ge*********@gmail.comwrote in message
news:11*********************@b58g2000hsg.googlegro ups.com...
>>>>Index.php is basically an html file uses a linked css file and when
its
included in the new file its referencing a css file in the wrong
spot.
I need to add "../" to the css file reference in Index.php to make
it
work.

If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.
Thanks, I'll try it. The reason I can't use absolute paths is because the
path on the remote server is different from the path that I have setup for
apache and therefore it does no good to hard code it. My only option there
is to setup apache to have the exact same dir structure as the remote
server. Ofcourse that might be the best thing and I guess I'll do it but
still need to know how to modify the file contents for other purposes.

Thanks,
Jon

Apr 19 '07 #9
Jo***********@Hotmail.com says...
To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">
Iv'e joined this thread late, so maybe I'm off track, but wouldn't the
following simple fix work:

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

Just tell all the scripts (regarless of where they are) that the style
sheet is to be sourced relative to the http document root.

GM
Apr 19 '07 #10

"Geoff Muldoon" <ge***********@trap.gmail.comwrote in message
news:MP************************@news.readfreenews. net...
Jo***********@Hotmail.com says...
>To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">

Iv'e joined this thread late, so maybe I'm off track, but wouldn't the
following simple fix work:

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

Just tell all the scripts (regarless of where they are) that the style
sheet is to be sourced relative to the http document root.

Tried it. Doesn't work.

I'll try again to be sure but from what I recall it has the same effect in
both cases.

Jon
Apr 19 '07 #11

"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:Tb***************@newssvr22.news.prodigy.net. ..
>
"Geoff Muldoon" <ge***********@trap.gmail.comwrote in message
news:MP************************@news.readfreenews. net...
>Jo***********@Hotmail.com says...
>>To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">

Iv'e joined this thread late, so maybe I'm off track, but wouldn't the
following simple fix work:

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

Just tell all the scripts (regarless of where they are) that the style
sheet is to be sourced relative to the http document root.


Tried it. Doesn't work.

I'll try again to be sure but from what I recall it has the same effect in
both cases.
Nope, doesn't work.

Apr 19 '07 #12

<ge*********@gmail.comwrote in message
news:11*********************@b58g2000hsg.googlegro ups.com...
>>>>Index.php is basically an html file uses a linked css file and when
its
included in the new file its referencing a css file in the wrong
spot.
I need to add "../" to the css file reference in Index.php to make
it
work.

If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.
using

<LINK REL=StyleSheet HREF="/Styles/Main.css" TYPE="text/css">

instead of

<LINK REL=StyleSheet HREF="Styles/Main.css" TYPE="text/css">

doesn't work when I do not include the the html file from a directory that
contains Styles/Main.css.

For some reason the absolute paths are not working. The browser is trying
not looking from the root but always from the current dir.

using code to change link still doesn't work

echo str_replace('"/Styles/Main.css"', '"/../Styles/Main.css"',
file_get_contents('../Main.php'); );

It does change the link properly but no matter what I use it does not find
the css file(I've tryed /.. and ../ but nothing works).
The directories are right but I can't seem to get the style sheet.
Apr 19 '07 #13

"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:2t***************@newssvr22.news.prodigy.net. ..
>
<ge*********@gmail.comwrote in message
news:11*********************@b58g2000hsg.googlegro ups.com...
>>>>>Index.php is basically an html file uses a linked css file and
>when its
>included in the new file its referencing a css file in the wrong
>spot.
>I need to add "../" to the css file reference in Index.php to make
>it
>work.

If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.

using

<LINK REL=StyleSheet HREF="/Styles/Main.css" TYPE="text/css">

instead of

<LINK REL=StyleSheet HREF="Styles/Main.css" TYPE="text/css">

doesn't work when I do not include the the html file from a directory that
contains Styles/Main.css.

For some reason the absolute paths are not working. The browser is trying
not looking from the root but always from the current dir.

using code to change link still doesn't work

echo str_replace('"/Styles/Main.css"', '"/../Styles/Main.css"',
file_get_contents('../Main.php'); );
(the extra ; is a bug... still doesn't work.
Apr 19 '07 #14
Message-ID: <hf***************@newssvr22.news.prodigy.netfro m Jon
Slaughter contained the following:
>Tried it. Doesn't work.

I'll try again to be sure but from what I recall it has the same effect in
both cases.

Nope, doesn't work.
Are you working on a live server or a development subdirectory?
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Apr 19 '07 #15

"Geoff Berrow" <bl******@ckdog.co.ukwrote in message
news:7l********************************@4ax.com...
Message-ID: <hf***************@newssvr22.news.prodigy.netfro m Jon
Slaughter contained the following:
>>Tried it. Doesn't work.

I'll try again to be sure but from what I recall it has the same effect
in
both cases.

Nope, doesn't work.

Are you working on a live server or a development subdirectory?
Both.

The issue seems this, I suppose the absolute directory is working... but the
links in the css file are not.

That is, the css file contains links to images for the background...

so in the css file there is lines like

background-image:url('images/someimage.gif');
But its not finding these images.

changing it to

background-image:url('/images/someimage.gif');

doesn't help either.

I guess I have to write a simple test case to see what the real problem is.
I can't tell if its not including the css or if it is but not the images
since theres not much in the css to tell the difference.
Its all work fine though as long as I'm accessing the css file from the root
dir but as soon as I try to reference it from a sub dir it gives me
problems.

Yeah, it seems to not be finding the images...

so the

background-image:url('/images/someimage.gif');

isn't working properly.
Ok, when I copy the Images directory to the Mathematics sub dir then
everything works...

so

background-image:url('/images/someimage.gif');

is trying to find the image in the sub directory instead of w.r.t to the
root dir.

Guess I gotta figure out what url actually does ;/
Thanks,
Jon
Apr 19 '07 #16

"Geoff Berrow" <bl******@ckdog.co.ukwrote in message
news:7l********************************@4ax.com...
Message-ID: <hf***************@newssvr22.news.prodigy.netfro m Jon
Slaughter contained the following:
>>Tried it. Doesn't work.

I'll try again to be sure but from what I recall it has the same effect
in
both cases.

Nope, doesn't work.

Are you working on a live server or a development subdirectory?

Ok, I believe its now working. I needed to use the ../ on the images. I
actually had this before but I guess I screwed up somewhere and then started
changing things but now everything seems to be working. Not sure why it
didn't work the first time.

Thanks,
Jon
Apr 19 '07 #17
Jon Slaughter wrote:
My only option there is to setup apache to have the exact same dir
structure as the remote server
Not the same directory structure, but the same URL structure. These are
different (and often entirely unrelated) things.

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Apr 19 '07 #18

"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:Jz******************@newssvr29.news.prodigy.n et...
Can I modify code that I have included using

<?php
include("../Index.php");
?>

The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot. I
need to add "../" to the css file reference in Index.php to make it work.

Thanks,
Jon
Ok, forget it. I guess its my incompetence. Not sure why it didn't work in
the first place but I probably should have coded the original html and css
file better. Had a few things mixed up and I suppose it wasn't the php part
that was wrong but I forgot I had some inline css that had relative links in
it and it wasn't find the the images.
Thanks,
Jon
Apr 19 '07 #19
ge*********@gmail.com wrote:
>>>>>>Index.php is basically an html file uses a linked css file and when its
>>included in the new file its referencing a css file in the wrong spot.
>>I need to add "../" to the css file reference in Index.php to make it
>>work.

If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.
Which includes another query to the webserver - and is very inefficient.
There's no reason to do this when the file is on the local filesystem.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #20
Jon Slaughter wrote:
<ge*********@gmail.comwrote in message
news:11*********************@b58g2000hsg.googlegro ups.com...
>>>>>>>Index.php is basically an html file uses a linked css file and when
>>>its
>>>included in the new file its referencing a css file in the wrong
>>>spot.
>>>I need to add "../" to the css file reference in Index.php to make
>>>it
>>>work.
If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.

Thanks, I'll try it. The reason I can't use absolute paths is because the
path on the remote server is different from the path that I have setup for
apache and therefore it does no good to hard code it. My only option there
is to setup apache to have the exact same dir structure as the remote
server. Ofcourse that might be the best thing and I guess I'll do it but
still need to know how to modify the file contents for other purposes.

Thanks,
Jon
Jon,

Did you even read my message earlier? The relative path does not need
to be dependent on the absolute path to your document root. They are
two entirely different things.

All of my sites use absolute paths for their include and require
statements. And all of them work both on test and production machines,
despite very different directory structures.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #21
Jon Slaughter wrote:
<ge*********@gmail.comwrote in message
news:11*********************@b58g2000hsg.googlegro ups.com...
>>>>>>>Index.php is basically an html file uses a linked css file and when
>>>its
>>>included in the new file its referencing a css file in the wrong
>>>spot.
>>>I need to add "../" to the css file reference in Index.php to make
>>>it
>>>work.
If index.php is HTML file (no parsing needed), you can "include" by
calling
<?php echo file_get_contents('../index.php'); ?>
to modify path, simply use str_replace or RegExp on
file_get_contents() return value, like so:
<?php echo str_replace('path/to/stylesheet.css', 'new/path/to/
stylesheet.css', file_get_contents('../index.php'); ?>

But it's really more clever to use absolute paths.

using

<LINK REL=StyleSheet HREF="/Styles/Main.css" TYPE="text/css">

instead of

<LINK REL=StyleSheet HREF="Styles/Main.css" TYPE="text/css">

doesn't work when I do not include the the html file from a directory that
contains Styles/Main.css.

For some reason the absolute paths are not working. The browser is trying
not looking from the root but always from the current dir.

using code to change link still doesn't work

echo str_replace('"/Styles/Main.css"', '"/../Styles/Main.css"',
file_get_contents('../Main.php'); );

It does change the link properly but no matter what I use it does not find
the css file(I've tryed /.. and ../ but nothing works).
The directories are right but I can't seem to get the style sheet.

Of course. "../Main.php" is a request to the webserver to fetch a file
one level below the root directory - which is not accessible to outside
requests.

And this is the crappiest way to go - see my note above about it
requiring a lot of additional and unnecessary work on the webserver.

Your problem is not the code. It's your screwed up test environment.
Straighten that out and it will work.

You're using a hammer to drive in a screw. And when that doesn't work,
you're trying a bigger hammer.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #22
Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:yf******************************@comcast.com. ..
>Jon Slaughter wrote:
>>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Mu******************************@comcast.co m...
Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:D5******************************@comcast. com...
>Jon Slaughter wrote:
>>Can I modify code that I have included using
>>>
>><?php
>>include("../Index.php");
>>?>
>>>
>>The Index.php file contains links that need to be modified to work.
>>Index.php is basically an html file uses a linked css file and when
>>its included in the new file its referencing a css file in the wrong
>>spot. I need to add "../" to the css file reference in Index.php to
>>make it work.
>>>
>>Thanks,
>>Jon
>Ensure your link is an absolute path relative to your website root.
>Then where you include index.php doesn't matter.
>>
It would actually be a bit more trouble since any time I want to upload
to the server to test I will have to change the link. Would be easier
just to have php just add "../" to one spot instead manually doing it
every time I upload to the server.
And why is that? I never have to change links when I upload to my
servers.
Um, because the directory structure differs on my server than my
computer? My server uses public_html to hold html files while my computer
doesn't. I suppose I could go mess with the apache config file and change
it though but it still doesn't solve my problem complete. I still need to
inject html files into containers in the html/php code.
So? Mine differs also - my test system is Windows and most of my hosts
are Unix. And my directory here is much different than the one on the
server. I just set up Apache to handle it. Much easier than trying to
screw around with files like you are.
>>e.g. when I do

<?php include ('SomeFile.php') ?>
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/SomeFile.php'); ?>

Use the features of the language.

To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">

But when I include the main file the styles/main.css is referenced from the
directory of that file... but there is not styles/main.css from in that
directory of that file unless it happens to be the root.

Got any more bright ideas?
Like I said - use

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

And get your test environment straightened out.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #23
Jon Slaughter wrote:
"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:Tb***************@newssvr22.news.prodigy.net. ..
>"Geoff Muldoon" <ge***********@trap.gmail.comwrote in message
news:MP************************@news.readfreenews .net...
>>Jo***********@Hotmail.com says...

To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">
Iv'e joined this thread late, so maybe I'm off track, but wouldn't the
following simple fix work:

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

Just tell all the scripts (regarless of where they are) that the style
sheet is to be sourced relative to the http document root.

Tried it. Doesn't work.

I'll try again to be sure but from what I recall it has the same effect in
both cases.

Nope, doesn't work.
It works if /styles is in the root directory of your website.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #24

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Pq******************************@comcast.com. ..
Jon Slaughter wrote:
>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:yf******************************@comcast.com ...
>>Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Mu******************************@comcast.c om...
Jon Slaughter wrote:
>"Jerry Stuckle" <js*******@attglobal.netwrote in message
>news:D5******************************@comcast .com...
>>Jon Slaughter wrote:
>>>Can I modify code that I have included using
>>>>
>>><?php
>>>include("../Index.php");
>>>?>
>>>>
>>>The Index.php file contains links that need to be modified to work.
>>>Index.php is basically an html file uses a linked css file and when
>>>its included in the new file its referencing a css file in the
>>>wrong spot. I need to add "../" to the css file reference in
>>>Index.php to make it work.
>>>>
>>>Thanks,
>>>Jon
>>Ensure your link is an absolute path relative to your website root.
>>Then where you include index.php doesn't matter.
>>>
>It would actually be a bit more trouble since any time I want to
>upload to the server to test I will have to change the link. Would
>be easier just to have php just add "../" to one spot instead
>manually doing it every time I upload to the server.
And why is that? I never have to change links when I upload to my
servers.
>

Um, because the directory structure differs on my server than my
computer? My server uses public_html to hold html files while my
computer doesn't. I suppose I could go mess with the apache config file
and change it though but it still doesn't solve my problem complete. I
still need to inject html files into containers in the html/php code.

So? Mine differs also - my test system is Windows and most of my hosts
are Unix. And my directory here is much different than the one on the
server. I just set up Apache to handle it. Much easier than trying to
screw around with files like you are.

e.g. when I do

<?php include ('SomeFile.php') ?>

<?php include ($_SERVER['DOCUMENT_ROOT'] . '/SomeFile.php'); ?>

Use the features of the language.

To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">

But when I include the main file the styles/main.css is referenced from
the directory of that file... but there is not styles/main.css from in
that directory of that file unless it happens to be the root.

Got any more bright ideas?

Like I said - use

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

And get your test environment straightened out.

Yes. You were right from the beginning. What I first thought you ment by
absolute paths was including the domain name which would just have been a
mess. When I realized that you can use / to refer a path from the root dir
and tired it did not work. It didn't work not because of that but because I
didn't change all the links to be absolute but only some... but I didn't
realize it. So I thought it must have been something else.

The good thing is, is now its working and now I know so next time I
shouldn't have this problem ;)

Thanks,
Jon
Apr 19 '07 #25
On Apr 19, 6:18 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
Jon Slaughter wrote:
Can I modify code that I have included using
<?php
include("../Index.php");
?>
The Index.php file contains links that need to be modified to work.
Index.php is basically an html file uses a linked css file and when its
included in the new file its referencing a css file in the wrong spot. I
need to add "../" to the css file reference in Index.php to make it work.
Thanks,
Jon

Ensure your link is an absolute path relative to your website root.
Then where you include index.php doesn't matter.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
Or, if you really want to do what you've asked to do, then you could,
instead of include-ing it into the script, and if it isn't ALL just
html and has some PHP needed to be parsed, you could fopen it, read
the contents, strreplace strings with whatever you want, then eval the
entire string. Not a good idea, pretty ugly, but there you have it :)

Apr 19 '07 #26
One last thing:
<?php

/* Remove link that brought us to this site to prevent recursion and
highlight that link */
$Link = "Mathematics";
$Dir = '/'.$Link.'/'.$Link.'.php';
$MainFile = str_replace('<a href="'.$Dir.'">'.$Link.'</a>', '<span
style="color:#FFFF00; text-decoration:underline;
font-weight:bold;">'.$Link.'</span>', file_get_contents('../Main.php'));
echo $MainFile;
?>

I'm searching for the link that user clicked on(going to try and take the
link from the url to generalize the code above later) so the user cannot
click on it again and there is some visual feedback to where the user is at
besides the address bar.

You can see what I mean at

http://www.JonSlaughter.com/Index.php

Clicking on mathematics removes the link at mathematics and changes the
style of it.

Is there any reason why I should't do this and just include main.php using
include '../Main.php';?

Hopefully I'll be able to generalize the code enough so that I will not have
to change it for each link but can just call it and it will figure out the
details. I guess ultimately I'll need to use regular expressions which
might slow things down? (Main.php is not a large file though and I never
expect it to grow, say, above 10k)
Thanks,
Jon


Apr 19 '07 #27
Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Pq******************************@comcast.com. ..
>Jon Slaughter wrote:
>>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:yf******************************@comcast.co m...
Jon Slaughter wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Mu******************************@comcast. com...
>Jon Slaughter wrote:
>>"Jerry Stuckle" <js*******@attglobal.netwrote in message
>>news:D5******************************@comcas t.com...
>>>Jon Slaughter wrote:
>>>>Can I modify code that I have included using
>>>>>
>>>><?php
>>>>include("../Index.php");
>>>>?>
>>>>>
>>>>The Index.php file contains links that need to be modified to work.
>>>>Index.php is basically an html file uses a linked css file and when
>>>>its included in the new file its referencing a css file in the
>>>>wrong spot. I need to add "../" to the css file reference in
>>>>Index.php to make it work.
>>>>>
>>>>Thanks,
>>>>Jon
>>>Ensure your link is an absolute path relative to your website root.
>>>Then where you include index.php doesn't matter.
>>>>
>>It would actually be a bit more trouble since any time I want to
>>upload to the server to test I will have to change the link. Would
>>be easier just to have php just add "../" to one spot instead
>>manually doing it every time I upload to the server.
>And why is that? I never have to change links when I upload to my
>servers.
>>
Um, because the directory structure differs on my server than my
computer? My server uses public_html to hold html files while my
computer doesn't. I suppose I could go mess with the apache config file
and change it though but it still doesn't solve my problem complete. I
still need to inject html files into containers in the html/php code.
>
So? Mine differs also - my test system is Windows and most of my hosts
are Unix. And my directory here is much different than the one on the
server. I just set up Apache to handle it. Much easier than trying to
screw around with files like you are.

e.g. when I do
>
<?php include ('SomeFile.php') ?>
>
<?php include ($_SERVER['DOCUMENT_ROOT'] . '/SomeFile.php'); ?>

Use the features of the language.

To bad this doesn't work. You don't seem to understand the issue. The
problem is that using the style sheet is not included properly.

e.g., in the main html file I have

<LINK REL=StyleSheet HREF="styles/main.css" TYPE="text/css">

But when I include the main file the styles/main.css is referenced from
the directory of that file... but there is not styles/main.css from in
that directory of that file unless it happens to be the root.

Got any more bright ideas?
Like I said - use

<LINK REL=StyleSheet HREF="/styles/main.css" TYPE="text/css">

And get your test environment straightened out.


Yes. You were right from the beginning. What I first thought you ment by
absolute paths was including the domain name which would just have been a
mess. When I realized that you can use / to refer a path from the root dir
and tired it did not work. It didn't work not because of that but because I
didn't change all the links to be absolute but only some... but I didn't
realize it. So I thought it must have been something else.

The good thing is, is now its working and now I know so next time I
shouldn't have this problem ;)

Thanks,
Jon

Great - the only thing better than fixing a problem is learning from it! :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 19 '07 #28

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Mr B | last post by:
Howdy, I want to set up an Include page in a cell of a table. Then I want to be able to change which page is included on the fly as the user moves the mouse of the various links on the page. ...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
2
by: Xiphias | last post by:
Hi, Im trying to change the color of a text box on a report that im printing from a form. On the form I got a check box that has to tricker the color of that textbox on the printed report....
5
by: Hank | last post by:
My Access 2000 code has been running for several years in our main plant. Now we need to install it, as a stand-along application, at remote sites, some of which are out of state. My problem is...
2
by: Hariharan S | last post by:
Hi Guys, Have an issue with the Font object. I have a text box in which I can enter text and I have included a small button which upon selection, should enable me to change the newly entered...
3
by: Joachim | last post by:
In the Install-Start-Welcome dialog - how can I change the text "Welcome to the MyApp Setup Wizard"? For instance, if I would like it to be in another language.
6
by: Evgeny Zoldin | last post by:
Hi ALL. I have the configuration: 1. WinXP PRO with MS IIS 5.0 and installed ASP.NET 2. ASP.NET application A configured to authenticate only users from local Users group. I would like to de...
0
by: sastwhc | last post by:
sastwhc wrote: > *Hi all > I try change language client side programatically.In my case farsi a > Right to Left Language,the curser direction changed by dir=rtl TAG > changed to correct direction...
13
by: sonald | last post by:
Hi, Can anybody tell me how to change the text delimiter in FastCSV Parser ? By default the text delimiter is double quotes(") I want to change it to anything else... say a pipe (|).. can anyone...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.