www.webdeveloper.com
Results 1 to 10 of 10

Thread: [RESOLVED] PHP/HTML issues

  1. #1
    Join Date
    Dec 2003
    Location
    A series of tubes known as the "internets"
    Posts
    2,166

    resolved [RESOLVED] PHP/HTML issues

    Man, it's been a long time since I posted here...

    I'm having issues with PHP generating what I need to. I have a very simple PHP setup: I have header.php, index.php and footer.php.

    Here's index.php (www.kayeskinner.com/ks2/index.php
    PHP Code:
    <?php
    $current 
    'index';

    include (
    'header.php');


    ?>

    <div id="content">
        <p>Blah, blah, blah</p>
    </div>

    <?php
    include ('footer.php');
    ?>
    The header.php file contains virtually all of the structure of the page, including the following code for my links bar:

    PHP Code:
                    <ul>
                      <li class="links" <?php if ($current == 'index') echo 'id="currentlink"' ?>><a href="index.php">home</a></li>
                      <li class="links" <?php if ($current == 'music') echo 'id="currentlink"' ?>><a href="music.php">music</a></li>
                      <?php if ($current == 'music') echo '
                      <li class="musiclinks"><a href="#head">wind ensemble</a></li>
                      <li class="musiclinks"><a href="#choir"><acronym title="Soprano Alto Tenor Bass">satb</acronym> choir</a></li>
                      <li class="musiclinks"><a href="#misc">solo/ensemble</a></li>
                      ' 
    ?>
                      <li class="links" <?php if ($current == 'bio') echo 'id="currentlink"' ?>><a href="bio.php">bio</a></li>
                      <li class="links" <?php if ($current == 'media') echo 'id="currentlink"' ?>><a href="media.php">media</a></li>
                      <li class="links" <?php if ($current == 'contact') echo 'id="currentlink"' ?>><a href="contact.php">contact</a></li>
                      <li class="links"><a href="http://www.facebook.com/benkayeskinner" target="_blank">facebook</a></li>
                      </ul>
    Except that I'm not getting those "currentlink" IDs to display; neither do the "musiclinks" classes on the music.php page. Thoughts?
    "Outside of a dog, a book is a man's best friend. Inside a dog, it is too dark to read." - Mark Twain

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,248
    I'd start by making sure all errors are displayed for now, in the hopes they'll get us pointed in the right direction:
    PHP Code:
    <?php
    ini_set
    ('display_errors'true);
    error_reporting(E_ALL);
    ?>
    I don't see any syntax issues, so my best guess (and only a guess) at this point is some sort of scoping issue causing $current to not be defined in the contexts where you are using it -- which should then show up as an "not defined" notice once all errors are displayed.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Mar 2005
    Location
    Behind you...
    Posts
    862
    On your homepage the 'currentlink' ID actually gets set, but for every link:
    HTML Code:
                      <li class="links" id="currentlink"><a href="index.php">home</a></li>
                      <li class="links" id="currentlink"><a href="music.php">music</a></li>
                                        <li class="links" id="currentlink"><a href="bio.php">bio</a></li>
                      <li class="links" id="currentlink"><a href="media.php">media</a></li>
                      <li class="links" id="currentlink"><a href="contact.php">contact</a></li>
                      <li class="links" id="currentlink"><a href="http://www.facebook.com/benkayeskinner">facebook</a></li>
    That's the HTML printed on the page when I viewed it. For the music page none of those IDs were set. And actually now that I look at it... Your code doesn't show the 'currentlink' if statement for the facebook link, but this is what I got when I loaded the index. Might not be a relavent detail, but is that the source that's active on your site?

    I'd search your code for all of the references to $current because you've definitely got something going on with that variable. Maybe even echo it out on the page just to see what your code thinks it is.
    "Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,248
    If I run the header code by itself and just hard-code a value for $current, it seems to run fine, e.g.:
    PHP Code:
    <?php $current 'music'// hard-coding value for $current ?>
                     <ul>
                      <li class="links" <?php if ($current == 'index') echo 'id="currentlink"' ?>><a href="index.php">home</a></li>
                      <li class="links" <?php if ($current == 'music') echo 'id="currentlink"' ?>><a href="music.php">music</a></li>
                      <?php if ($current == 'music') echo '
                      <li class="musiclinks"><a href="#head">wind ensemble</a></li>
                      <li class="musiclinks"><a href="#choir"><acronym title="Soprano Alto Tenor Bass">satb</acronym> choir</a></li>
                      <li class="musiclinks"><a href="#misc">solo/ensemble</a></li>
                      ' 
    ?>
                      <li class="links" <?php if ($current == 'bio') echo 'id="currentlink"' ?>><a href="bio.php">bio</a></li>
                      <li class="links" <?php if ($current == 'media') echo 'id="currentlink"' ?>><a href="media.php">media</a></li>
                      <li class="links" <?php if ($current == 'contact') echo 'id="currentlink"' ?>><a href="contact.php">contact</a></li>
                      <li class="links"><a href="http://www.facebook.com/benkayeskinner" target="_blank">facebook</a></li>
                      </ul>
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Dec 2003
    Location
    A series of tubes known as the "internets"
    Posts
    2,166
    Quote Originally Posted by NogDog View Post
    I'd start by making sure all errors are displayed for now, in the hopes they'll get us pointed in the right direction:
    PHP Code:
    <?php
    ini_set
    ('display_errors'true);
    error_reporting(E_ALL);
    ?>
    I don't see any syntax issues, so my best guess (and only a guess) at this point is some sort of scoping issue causing $current to not be defined in the contexts where you are using it -- which should then show up as an "not defined" notice once all errors are displayed.
    I added this in and see nothing new.
    "Outside of a dog, a book is a man's best friend. Inside a dog, it is too dark to read." - Mark Twain

  6. #6
    Join Date
    Dec 2003
    Location
    A series of tubes known as the "internets"
    Posts
    2,166
    I threw this in:
    PHP Code:
    <p> <?php echo $current?></p>
    and it displays "index" like it should.
    "Outside of a dog, a book is a man's best friend. Inside a dog, it is too dark to read." - Mark Twain

  7. #7
    Join Date
    Mar 2005
    Location
    Behind you...
    Posts
    862
    Not to sound invasive, but I do have to ask, is that all of the code you have that loads when the index.php page is loaded? If I copy and paste all of the code from your original post (taking out the footer line) it works exactly as it should.

    I feel like there has to be something else I'm not seeing that is having some odd effect on how everything gets loaded on your site.
    "Given billions of tries, could a spilled bottle of ink ever fall into the words of Shakespeare?"

  8. #8
    Join Date
    Dec 2003
    Location
    A series of tubes known as the "internets"
    Posts
    2,166
    Here are the full files.

    header.php:
    PHP Code:
    <html lang="en">

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script>
        if ( window.addEventListener ) {
                var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
                window.addEventListener("keydown", function(e){
                        kkeys.push( e.keyCode );
                        if ( kkeys.toString().indexOf( konami ) >= 0 )
                                window.location = "http://www.youtube.com/watch?v=oHg5SJYRHA0&feature=fvw";
                }, true);
        }
        </script>
        <title><?php echo $page_title ?>kayeskinner dot com</title>
        <link rel="stylesheet" type="text/css" href="ks2.css">
        <link rel="shortcut icon" href="favicon.png" />

    </head>
    <body>
    <div id="container">
        <div id="head">
        </div>
        
        <div id="body">
            <div id="links">
                    <ul>
                      <li class="links" <?php if ($current == 'index') echo 'id="currentlink"' ?>><a href="index.php">home</a></li>
                      <li class="links" <?php if ($current == 'music') echo 'id="currentlink"' ?>><a href="music.php">music</a></li>
                      <?php if ($current == 'music') echo '
                      <li class="musiclinks"><a href="#head">wind ensemble</a></li>
                      <li class="musiclinks"><a href="#choir"><acronym title="Soprano Alto Tenor Bass">satb</acronym> choir</a></li>
                      <li class="musiclinks"><a href="#misc">solo/ensemble</a></li>
                      ' 
    ?>
                      <li class="links" <?php if ($current == 'bio') echo 'id="currentlink"' ?>><a href="bio.php">bio</a></li>
                      <li class="links" <?php if ($current == 'media') echo 'id="currentlink"' ?>><a href="media.php">media</a></li>
                      <li class="links" <?php if ($current == 'contact') echo 'id="currentlink"' ?>><a href="contact.php">contact</a></li>
                      <li class="links"><a href="http://www.facebook.com/benkayeskinner" target="_blank">facebook</a></li>
                      </ul>
            </div>
            <!--End navigation-->
    index.php:
    PHP Code:
    <?php
    $current 
    'index';

    include (
    'header.php');

    ?>

    <div id="content">
        <p>Ben Kaye-Skinner is a Nebraska-based composer, arranger, performer, conductor and music educator. As a music educator, he teaches 5-12 band, 9-12 choir, jazz band, pep band, marching band and show choir at Fillmore Central Public Schools in Geneva, <acronym title="Nebraska">NE</acronym>. He has composed and arranged for soloists and ensembles young and old across Nebraska. <a href="bio.html">Read more...</a></p>
        <hr style="border-color:#600; color:#600; background-color:#600">
        <p>Welcome, all, to the freshly-redesigned kayeskinner.com. It's been over a year in the making, and I'm glad to finally roll it out. Please feel free to drop me a note if you like it (or if you don't) and browse around to check out all of the music.</p>
    </div>

    <?php
    include ('footer.php');
    ?>
    footer.php:
    PHP Code:
    </div>
    </div>

    <div id="footer">
        <h3>all content © 2007-<?php echo date("Y");?> ben kaye-skinner unless noted otherwise.</h3>
    </div>    
        
        
    </body>
    </html>
    "Outside of a dog, a book is a man's best friend. Inside a dog, it is too dark to read." - Mark Twain

  9. #9
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,248
    Looks okay to me:

    EDIT: Except for that undefined variable notice for $page_title.

    HTML Code:
    <html lang="en">
    
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script>
        if ( window.addEventListener ) {
                var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
                window.addEventListener("keydown", function(e){
                        kkeys.push( e.keyCode );
                        if ( kkeys.toString().indexOf( konami ) >= 0 )
                                window.location = "http://www.youtube.com/watch?v=oHg5SJYRHA0&feature=fvw";
                }, true);
        }
        </script>
        <title><br />
    <b>Notice</b>:  Undefined variable: page_title in <b>C:\wamp\www\test\header.php</b> on line <b>15</b><br />
    kayeskinner dot com</title>
        <link rel="stylesheet" type="text/css" href="ks2.css">
        <link rel="shortcut icon" href="favicon.png" />
    
    </head>
    <body>
    <div id="container">
        <div id="head">
        </div>
    
        <div id="body">
            <div id="links">
                    <ul>
                      <li class="links" id="currentlink"><a href="index.php">home</a></li>
                      <li class="links" ><a href="music.php">music</a></li>
                                        <li class="links" ><a href="bio.php">bio</a></li>
                      <li class="links" ><a href="media.php">media</a></li>
                      <li class="links" ><a href="contact.php">contact</a></li>
                      <li class="links"><a href="http://www.facebook.com/benkayeskinner" target="_blank">facebook</a></li>
                      </ul>
            </div>
            <!--End navigation-->
    <div id="content">
        <p>Ben Kaye-Skinner is a Nebraska-based composer, arranger, performer, conductor and music educator. As a music educator, he teaches 5-12 band, 9-12 choir, jazz band, pep band, marching band and show choir at Fillmore Central Public Schools in Geneva, <acronym title="Nebraska">NE</acronym>. He has composed and arranged for soloists and ensembles young and old across Nebraska. <a href="bio.html">Read more...</a></p>
        <hr style="border-color:#600; color:#600; background-color:#600">
        <p>Welcome, all, to the freshly-redesigned kayeskinner.com. It's been over a year in the making, and I'm glad to finally roll it out. Please feel free to drop me a note if you like it (or if you don't) and browse around to check out all of the music.</p>
    </div>
    
    </div>
    </div>
    
    <div id="footer">
        <h3>all content  2007-2014 ben kaye-skinner unless noted otherwise.</h3>
    </div>
    
    
    </body>
    </html> 
    Last edited by NogDog; 03-10-2014 at 06:32 PM.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  10. #10
    Join Date
    Dec 2003
    Location
    A series of tubes known as the "internets"
    Posts
    2,166
    It's defined on each other page besides index.php.


    HERE IS THE THING:
    I just checked, after working on some other files for a couple hours, and it appears to be working now. Go team, I guess...
    "Outside of a dog, a book is a man's best friend. Inside a dog, it is too dark to read." - Mark Twain

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles