Jump to content

Page not rendering well

- - - - -

  • Please log in to reply
6 replies to this topic

#1
tayolad

tayolad

    Newbie

  • Members
  • PipPip
  • 27 posts
I created 3 folders: one for my php scripts, one for my css files and one for my javascript files. My index.php is in www (public folder). This file, is expected to use the css file in the ../mycssfile/ folder. This is my code:

<link rel=stylesheet type=text/css href="../allmyfiles/mycssfile/major_pa.css" />
and
require_once('../allmyfiles/myphpincludes/MyFunctions.php');

However, this did not work. I really dont know why.

can someone help me pls.

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
The client is not supposed to be able to access files below document root. ../ will be invisible, except only to PHP.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
tayolad

tayolad

    Newbie

  • Members
  • PipPip
  • 27 posts
If I get you correctly: The css folder and the js folder should be created under the public folder (www)? right? But what about my include files? Must I put then under the public folder? see this: require_once('../allmyfiles/myphpincludes/MyFunctions.php'); why is it not working? at least, PHP is the one interpreting the line. Pls help

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
PHP runs on the server (and can access ../allmyfiles). CSS and HTML runs on the client not the server (and cannot access ../allmyfiles). You will need to place the CSS folder above the document root so that the public client can view it. You can still leave PHP scripts under document root.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#5
tayolad

tayolad

    Newbie

  • Members
  • PipPip
  • 27 posts
Thank you very much Alex. I think I can figure out the principle. However, I am confused about what you mean by 'Document Root'. Please explain to me. I am confused on this matter.

Thank you

#6
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
I will try to explain it easier.

Your folder is www, you should put all your files in here, such as www/index.php, or www/allmyfiles/cssfile/major_pa.css

You cannot access files that are not in the www folder, so ../allmyfiles will not work for CSS. You must move them inside the www folder and change your page to point to the new location.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#7
tayolad

tayolad

    Newbie

  • Members
  • PipPip
  • 27 posts
Thank you very much Alex. You have solved my worry.

Meanwhile, I wish to make a suggestion to Codecall. Is it not possible for the titles to be arranged at the Main page of each Forum group (in a div or listbox) for easy access to prevent duplication of questions? The way it is arranged, people with slow/moderate speed (access) find it a little difficult browsing the titles. Therefore, instead of getting their problems solved without bothering people, they go ahead to ask the same question that have been solved prior.

Just a suggestion.

Thanks




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users