Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: echo problems w/ included pages

  1. #11
    Join Date
    Jul 2008
    Posts
    138
    Thanks
    13
    Thanked 1 Time in 1 Post

    Default

    Normally when I "include" a file it contains variables that my main page is using so it seems a little odd that your include file is just echoing the value. Sometimes scripts will be built to include a head.php file in the main page but within that head.php there is another included file like a config.php file that references all the site details and such. ie. a content management system may use something similar or the head info is pulled from a database.

    It seems logical but I can't offer an explanation on why only 1 set of the code in your last post works, and why the 2nd setup doesn't. Query strings(getting info from URL)(simple switch statement could even be applied) or a database might be the only option to update the meta data dynamically on all your static pages.

    The head data will pretty much remain the same on each page so if you really want to keep the meta tags and echo them out in a seperate file it might be just as easy to do something like this...
    PHP Code:
    <?php 
    $pageTitle
    ="Reel Lumber Service | Wholesale Hardwood &amp; Pine Lumber, Mouldings, Plywood, Custom Milling"
    $pageDescription "speculative website build";
    $pageKeywords "adrian testa-avila, custom-anything, custom, web, web design, web site, html, css, php, javascript";
    $pageRobots "noindex, nofollow";
    //end of content changes for each page
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <?php include ("/path/to/head.php"); //head only echos the meta tags ?>
    <!-- if you wanted to add other meta info on a specific page you could do it here -->
    </head>
    <body>
    </body>
    </html>
    Create all your static pages in a similar format and change your meta info at the top, and the included file head.php is seperate and echos the common meta info. Anytime you create a new file you update the php info at the top in that one file which is really the same as coding it in html but using php variables and echoing them out.
    Last edited by ?foru; 05-20-2009 at 02:06 AM.

  2. #12
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    I've got it figured out. it had to do with my webhost and their default settings for PHP. For example, I didn't actually have php5 until yesterday, when I finally finished beating the .htaccess file over tech support heads. THEN, I had to change all my absolute paths (which used to be the only way it would work) to
    PHP Code:
    $_SERVER['DOCUMENT_ROOT']."/path/to/whatever.php" 
    because they have all the php5 defaults screwed with also. Now that I've got this figured out, we'll see about my SQLite problems. I'm getting *different* error messages now, at least that's something!
    Thanks a bunch for sticking with this, ?foru. You've been very helpful.
    Last edited by traq; 05-21-2009 at 01:03 AM.

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
  •