SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,388
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)

    PHP doesn't process CSS pages?

    I uploaded my PHP and CSS pages to my new external server at CrystalTech. The CSS pages did not style the PHP pages. Upon asking Support about this, here is the answer I got:

    "I've found the issue. PHP does not process the actual .css file extention. So if you notice in your /css directory all your .css files are now .php. You'll need to update all your css links to reflect the new .php extention. I tested this and you can see it on the home page of the site. "

    Is it true that pages with a php extension (not talking about includes) does not process css? I've never heard of that. Will I have to change my php extensions to htm to make the css work?

    Thanks for any light you can shed on this issue.

    Steve

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    It sounds as if they think your css files have got PHP instructions in them.
    PHP Code:
    //stuff like this
    <?php
    if( true )
    echo 
    '.bold {font-weight: bold ;}';
    ?>
    Have they?

    Or do they contain straight css rules?
    Code:
    .bold {
    font-weight: bold ;
    }

  3. #3
    SitePoint Enthusiast DidUSayScript's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your CSS is best included in the <head> parto of your page ( HTML).

    If you are not doing a "require()" or "include()", the php has nothing to do with your css to be honest - unless I am misunderstanding the entire problem.

    One way to include a style sheet would be as follows

    Code HTML4Strict:
    <link type="text/css" rel="Stylesheet" href="inc/style.css">

    I copied this line from a working system (index.php) - so it works - that I can guarantee you !!
    ______________________
    Enjoying life is not about what you get from it ....
    ...... but how you perceive what you get

    www.jerilimited.co.uk

  4. #4
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,388
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by DidUSayScript View Post
    Your CSS is best included in the <head> parto of your page ( HTML).

    If you are not doing a "require()" or "include()", the php has nothing to do with your css to be honest - unless I am misunderstanding the entire problem.

    One way to include a style sheet would be as follows

    Code HTML4Strict:
    <link type="text/css" rel="Stylesheet" href="inc/style.css">
    I am using this method to call the CSS.
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"

    <
    html xmlns="http://www.w3.org/1999/xhtml">

    <
    head>
    <
    meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <
    link rel="stylesheet" type="text/css" href="../css/search.css" />
    <
    link rel="stylesheet" type="text/css" media="print" href="../css/search_print.css" />
    <
    title>Power</title>
    </
    head
    Some of the PHP sections (enclosed with <?php and ?> tags) include references to styles on the external css, like this "celltable" css:

    PHP Code:
    echo "<td class='celltable'>";
    echo 
    "<p style='text-align:center' padding-top:'10px'><strong>$PartNo</strong><br />$ItemName</p><div class=$Brand>$thumb</div>\n"
    So should all my .php pages, except for the pure php includes, end in .htm instead? Or should I make the css as a php include and put it in the <head> area? How would the page know which was the print css and which was the screen css if I made them includes?

    I forgot to mention that the php/css system worked just fine in WAMP on my machine. It failed only after I uploaded the folders to my external server - same folder configuration as my local machine.
    Thanks,
    Steve
    Last edited by StevenHu; Oct 7, 2008 at 09:09. Reason: [added last paragraph.]

  5. #5
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    I cannot see anything you are doing wrong there.

    Edit:



    Thats a potential error in addressing
    <link rel="stylesheet" type="text/css" href="../css/search.css" />

    if /css is a top level directory why not just stick with the simpler:
    <link rel="stylesheet" type="text/css" href="/css/search.css" />


  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why do you think php has anything to do with this?
    Do your .css files contain php code? If not, this is not a php issue.

  7. #7
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,388
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by crmalibu View Post
    Why do you think php has anything to do with this?
    Do your .css files contain php code? If not, this is not a php issue.
    The CSS is in the head of my php pages. My external CSS has always worked with my html pages. Now that I'm into PHP, the CSS has stopped working once uploaded. I am trying to figure out if the php extension is the culprit, and if so, whether I should rename my php pages, except for the includes, as htm.

    However, the php/css pages have worked fine on my local WAMP machine.

    That's why I put this in a PHP thread. I thought more php coders would know about css than css people about php.

    Steve

  8. #8
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Sounds like your support has got the wrong end of the stick here. It's pretty bad that they'd just rename all your css files to php without you asking, but it sounds like there is a problem that isn't php related. I'd name all the files back if i were you.

  9. #9
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,388
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Stormrider View Post
    Sounds like your support has got the wrong end of the stick here. It's pretty bad that they'd just rename all your css files to php without you asking, but it sounds like there is a problem that isn't php related. I'd name all the files back if i were you.
    I wanted to make sure this problem was their fault and not mine before I go looking for another host.

    Thanks!

  10. #10
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This has nothing to do with php. Probably not your hosts fault either.

    I'm going to bet you have not set your url paths correctly.
    Make the urls absolute to test, eg
    Code:
    instead of
    <link rel="stylesheet" type="text/css" href="../css/search.css" />
    
    use
    <link rel="stylesheet" type="text/css" href="http://example.com/css/search.css" />
    Obviously, make sure the files exist with the .css extension at the url you specify.

    Clear your browser cache.

  11. #11
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,388
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    I made them absolute. That did not work either. The pages don't work with an htm extension either. Puzzling.

    Isn't the php on an html page supposed to work anyway if all the php is wrapped in the php tags? That's how my php pages are set up. Normal html is outside the php tags, and all php is inside the php tags.

    Steve
    Last edited by StevenHu; Oct 7, 2008 at 11:13. Reason: added second para

  12. #12
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And when you goto
    http://example.com/css/search.css

    in your browser, can you see the css text?

    Can you post a link to one of the pages which is not working?

  13. #13
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,388
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    OK, get a permission denied notice, #403. That means the css page can't be read by the system. I had checked the permission files and the pages are marked for Read and Execute for everyone. So there seems to be a bug in their system. I'll get on this with their support and see what they think.

    Everything worked fine on my system, then I had uploaded the folders as is, with the same file/folder relationships. It seems to be CrystalTech's problem at this point.

  14. #14
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You say you checked the permissions of the files - what about the folder they all live in? Also, have you got an .htaccess file in there causing problems maybe?

  15. #15
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,388
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Here is Support's reply:

    "What I have done so far is mapped the .css to the PHP5 executable."

    It seems that he needed to go into php.ini or somewhere to get it working. Now it works as expected in IE, but does not work in FF!

    According to the site, I can set permissions by clicking on checkboxes, for Everyone, Myself, and the system. The Read and Execute files have been checked, so that is not hindering. The main folder has Read enabled.

    I'll get back to Support to ask why it doesn't work in FF. Very curious!

    Steve

  16. #16
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I can give you that answer here.

    Since the CSS files are now interpreted by PHP, they will come back from the browser with a content type of text/plain, whereas css files are normally text/css. Internet Explorer ignores this difference, but firefox doesn't.

    Either stop the css files being interpreted by php (unless you need it), or add this to the top of every file, on the first line - no content can appear before it in each file:

    PHP Code:
    <?php header("Content-type: text/css"); ?>
    There might be a way to set the content-type using an .htaccess file as well, but I've never managed to find a way to do it.

  17. #17
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you confused your tech guy.
    Like when you came here, you had this idea that your problem was somehow related to php. It's not related to php at all. You would have the exact same problem if php had never existed and you only used .html files.

    You have probably given him the impression that you want php to parse your css files. You don't. Having php parse css files when you don't need it to will destroy the browsers ability to cache the files(unless you want to write a php script which will send proper cache headers and properly respond to conditional http requests...don't go there), not to mention they will load slower.

    Tell him not to have php parse the css files. Then link to a css file and show him the permission denied error, because that is the problem here.

  18. #18
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,388
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    crmalibu, I think you're right. I'll let Support know.

    Stormrider, I tried your suggestion. Unfortunately, all the files appear on my WAMP as text. I'd like the native files to work on both servers, so I'll remove the notice.

    Thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •