SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    different results in css when using php

    Hello

    I hope this is the right forum - pls redirect me if I am wrong. I put it here because the problem only occurs using IE6 under certain circumstance so I decided it must be the CSS.

    I have read cover to cover Ian Lloyd's "Build Your Own Website" and based a website on it ... I didn't know it could be so easy!! Being a newbie its amazing to take an old broken mixed up site and recreate. I am awaiting delivery of Advanced CSS - maybe the answer to my question is in there ...

    I have created two identical sites ... one using straight xhtml and css, the other the same but calling the body content with a simple php script (which I found on the original site and realised what it could do). On the php site there are two issues ... font size (eg I have had to reduce font in some places in php site) and alignment - on three of the pages in php site the h2 which is the first element in the body content has dropped around 10 or so pixels (as has an image floated to the right on one of the pages).

    This anomaly occurs in IE6 but not in Opera 9.

    Here are two links to the sites ...

    http://members.iinet.net.au/~allsaint@ihug.com.au (no php)
    http://members.iinet.net.au/~dbensted (php - home page heading low and picture at right hand side is low)

    Many thanks if you can help me with this - it isn't breaking the site but I would like to learn from it.

    Deb

  2. #2
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello, and welcome to Sitepoint! You have the right forum, but ironically the problem is not with the stylesheet. It's with the XHTML output from the PHP scripts you're using (which means the PHP is the culprit, not the CSS or the XHTML).

    You have content above your DOCTYPE, which is throwing the browsers into quirks mode (in this case, even FireFox).
    HTML Code:
      <!--<br />
     <b>Warning</b>:  session_start(): Cannot send session cookie - headers already sent by (output started at /u/d/dbensted/index.php:1) in <b>/u/d/dbensted/index.php</b> on line <b>4</b><br />
     <br />
     <b>Warning</b>:  session_start(): Cannot send session cache limiter - headers already sent (output started at /u/d/dbensted/index.php:1) in <b>/u/d/dbensted/index.php</b> on line <b>4</b><br />
     -->
    However, it looks like this is uniquely a PHP problem (the headers have already been sent).

    If you can post the PHP code, one of our PHP experts will be able to help you out.

  3. #3
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK - here is the whole index.php

    I had commented out the top bit because it looked like a password system that the original web person had done but I wasn't sure whether to get rid of it or not. I tried deleting it but it made no difference ... but I am posting it as is here so you can see the whole thing. I hope I have done it properly.

    Many thanks ... Deb

    <!--<?php

    global $do, $pass, $password, $isauth, $page;
    session_start();
    $pass = "e99a18c428cb38d5f260853678922e03";

    if ($_GET['do'] == "logout") {
    unset($_SESSION['isauth']);
    session_destroy();
    $isauth = "0";
    } elseif (isset($_SESSION['isauth'])) {
    $isauth = "1";
    } elseif (md5($_POST['password']) != $pass) {
    unset($_SESSION['isauth']);
    session_destroy();
    $isauth = "0";
    } elseif (md5($_POST['password']) == $pass) {
    $isauth = "1";
    $_SESSION['isauth'] = "1";
    }
    ?>-->

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>All Saints' Anglican Church Balgowlah</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="asfresh.css" rel="stylesheet" type="text/css" />
    </head>

    <body>
    <div id="header">
    <div id="site-branding">
    <h1><img src="images/logo_left.jpg" alt="All Saints' Logo" width="513" height="60" /></h1>
    </div><!-- site-branding -->

    <div id="tagline">
    <div id="tag-email">
    <p>18 Boyle St Balgowlah NSW 2093 email <a href="mailto:allsaint@ihug.com.au" title=
    "allsaint@ihug.com.au">allsaint@ihug.com.au</a></p>
    </div><!-- end of tag-email div -->

    <p><span class="fun">"Growing Disciples of Jesus Christ"</span></p>
    </div><!-- end of tagline div -->
    </div><!-- end of header div -->

    <div id="navigation">
    <ul>
    <li><a href="?page=home">Home</a></li>

    <li><a href="?page=aboutus">About Us</a></li>

    <li><a href="?page=services">Services</a></li>

    <li><a href="?page=meetthestaff">Meet the Staff</a></li>

    <li><a href="?page=ministries">Ministries</a></li>

    <li><a href="?page=youth">Youth</a></li>

    <li><a href="?page=contact">Contact Us</a></li>

    <li><a href="?page=links">Links</a></li>

    <li><a href="?page=photoalbum">Photo Album</a></li>

    <li><a href="?page=downloads">Downloads</a></li>
    </ul>
    </div><!-- end of navigation div -->

    <!-- INDIVIDUAL PAGE CONTENT STARTS HERE -->

    <div id="bodycontent">
    <?php

    if (!$_GET['page']) {
    include("home.html");
    } elseif ($_GET['page'] == "members") {
    include("members.php");
    } elseif ($_GET['page'] == "contact") {
    include("contact.php");
    } elseif (isset($_GET['page']) && $page != "members" && $page != "youth") {
    $page = $_GET['page'];
    include("$page.html");
    }

    ?>
    </div><!-- end of bodycontent div -->
    </body>
    </html>

  4. #4
    Non-Member deathshadow's Avatar
    Join Date
    Jul 2006
    Location
    Dublin, NH
    Posts
    901
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, your problem here is kinda obvious if you know what to look for - in this case you have written a html file that contains php in it, INSTEAD of a php that contains HTML in it.

    The 'comments' around the <?php markers are COMPLETELY unnecessary, as the server will remove the php to begin with... What's happening is that comment is getting sent as http data, starting the http session. Once that is done, you cannot start session handling. In theory on the users end, if the session handling DID work (which it can't) they would be recieving <!----> - anything inside <?php ?> is removed by the server, you NEVER need to comment it out... unless of course your server doesn't have PHP installed.

    Quite literally, change:
    <!--<?php
    to
    <?php

    and the
    ?>-->
    to
    ?>

    and you SHOULD be good to go, although you may end up having to wrap all the html inside an echo command... I almost never let my php files output html without wrapping them in an echo, partly for consistancy and ease of moving common items into variables, but also for security reasons as I tend to wrap the option of HTML output inside a conditional should session verification fail.

    Also using echo you can cache the output for compression (zlib), and burst the result instead of hanging the connect over time. Uses more memory but generally lighter on the cpu and maxconnects.

  5. #5
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Leave it to deathshadow to cover my back while I go get breakfast... .

  6. #6
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much for your trouble.

    I tried what you said - uncommented the php but instead of the errors occuring privately, and the page rendering fairly normally, the errors appeared at the top of the page.

    As I have no idea what the rest of your reply meant I think that I will revert to just xhtml and css until I know a little more - I obviously need some php lessons. As I said, I inherited a real mess of a site and used one of your books to learn xhtml and css to get this far. The old site, with the php code in situ, is operational with no errors but I can't see where the differences are. So I will do some more personal learning and come back here when I 've got a bit more on board. I can't see a basic php book here - is there a resource where I could start?

    Thanks again for your trouble.

    Deb

  7. #7
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


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
  •