Help - Search - Members - Calendar
Full Version: PHP Help...
Movable Type Community Forum > Additional Resources > Tips and Tricks
toon-time
Help...

I am trying to get my php to work on my site. I am trying to get my latest blog entry on my main index page along with the calendar in the left nav bar.

I have created two templates that are called calendar.php and content.php.

I call them with the following code on my main index.htm page.
CODE
<?php
include('http://www.toon-time.com/weblog/content.php');
?>


and
CODE
<div class="calendar" align="center">
<?php include ("http://www.toon-time.com/weblog/calendar.php"); ?>
</div>


Anyone have any ideas why this is not working? My site is http://www.toon-time.com

Thanks for any help. smile.gif
kadyellebee
Can we have a direct link to the page you are having difficulties with? The PHP error message may give us more info.

For newer versions of PHP, a PATH rather than a URL should be used in an include statement. For example:
http://your-site.com/blog/calendar.php is a URL
/home/USER/public_html/blog/calendar.php is a path

Kristine
charle97
change the extension of your index file to .php and look into what kristine said too.
toon-time
No dice guys... tried both things (path and making index.php)

The direct link to my site is http://www.toon-time.com

it's the first page I am trying to get my blog and calendar to show up on. Right now there is just a big blank white spot in the content section where I expect the blog to be.

-Greg
charle97
show the code of the whole page. make sure that you've rebuilt both calendar.php and content.php.
toon-time
Here are the contents of my content.php file....
CODE
<div class="blog">
<h2 class="date">
January 11, 2004
</h2>
<div class="blogbody">
<a name="000017"></a>
<h3 class="title">Test Entry</h3>
<p>This is a test entry</p>
<div class="posted">Posted by gregtoon at [URL=http://www.toon-time.com/weblog/archives/000017.html]
</div>
</div>
</div>


The code for my index page is quite large.  I've just pasted the part of the code you are probably interested in.  If you wan the whole page, let me know and I will post it.  As you can see, I tried it with just the path and the URL..

 <!-- START PAGE NAV -->
 <div id="pageNav">
   <div id="sectionLinks">
     <a href="weblog">Blog[/URL] [URL=loft] <a href="adventures">Adventures
     [/URL] [URL=proposal] <a href="wedding">Wedding[/URL]
  [URL=photos] <a href="guestbook.htm">Guestbook[/URL]
   </div>

    <!-- ************ MOBLOG *********** -->
    <div class="moblog" align="center">
 <h3>MOBLOG</h3>  
       <script language="javascript" type="text/javascript" src="http://toon-time.textamerica.com/mypage.asp"></script>
    [URL=http://toon-time.textamerica.com]Click to see more Photos</strong>[/URL]    </div>
    <!-- ************ MOBLOG END ************ -->
   
    <!-- ************ CALENDAR *********** -->
    <div class="calendar" align="center">
 <?php include ("http://www.toon-time.com/weblog/calendar.php"); ?>
    </div>
    <!-- ************ CALENDAR END ************ -->
    <div class="relatedLinks">
     <h3>Everyday Links</h3>
     [URL=http://www.bu.edu/athletics] <a href="http://www.westoverschool.org">Westover[/URL] [URL=http://www.wankinsong.com]      [/URL] [URL=http://www.campwashington.org] <a href="http://www.dailyfreepress.com">Daily Free Press[/URL]
  [URL=http://www.juicynote.com] <a href="http://www.tivocommunity.com">Tivo Community[/URL]
  [URL=http://www.textamerica.com] <a href="http://www.uscollegehockey.com/">USCHO.com[/URL]
   </div>

 </div>
 <div id="content">
   <!-- ********** MAIN SECTION STARTS HERE ************* -->

<!-- ************ BLOG *********** -->

<?php
include('/weblog/content.php');
?>

<!-- ************ BLOG END ************ -->


EDITED to use CODE tags around code, so that the board doesn't process it.
charle97
sorry i meant the code, showing the html and php code, for the page you're trying to pull content.php and calendar.php into.
toon-time
here is the code of my main index.htm page

....
CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- DW6 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Toon-Time.com</title>
<link rel="stylesheet" href="emx_nav_left.css" type="text/css">
<script type="text/javascript">
<!--
var time = 3000;
var numofitems = 7;

//menu constructor
function menu(allitems,thisitem,startstate){
 callname= "gl"+thisitem;
 divname="subglobal"+thisitem;  
 this.numberofmenuitems = 7;
 this.caller = document.getElementById(callname);
 this.thediv = document.getElementById(divname);
 this.thediv.style.visibility = startstate;
}

//menu methods
function ehandler(event,theobj){
 for (var i=1; i<= theobj.numberofmenuitems; i++){
   var shutdiv =eval( "menuitem"+i+".thediv");
   shutdiv.style.visibility="hidden";
 }
 theobj.thediv.style.visibility="visible";
}
   
function closesubnav(event){
 if ((event.clientY <120)||(event.clientY > 200)){
   for (var i=1; i<= numofitems; i++){
     var shutdiv =eval('menuitem'+i+'.thediv');
     shutdiv.style.visibility='hidden';
   }
 }
}
// -->
</script>
</head>
<body onmousemove="closesubnav(event);">
<div class="skipLinks">skip to: <a href="#content">page content</a> | <a href="pageNav">links on this page</a> | <a href="#globalNav">site navigation</a> | <a href="#siteInfo">footer (site information)</a> </div>
<div id="masthead">
 <h1 id="siteName"><img src="images/banner.gif" width="600" height="85"></h1>
 <div id="globalNav">
   <img alt="" src="gblnav_left.gif" height="32" width="4" id="gnl"> <img alt="" src="glbnav_right.gif" height="32" width="4" id="gnr">
   <div id="globalLink">
     <a href="weblog/index.htm" id="gl1" class="glink" onmouseover="ehandler(event,menuitem1);">Blog</a>
  <a href="loft/index.htm" id="gl2" class="glink" onmouseover="ehandler(event,menuitem2);">Loft</a>
     <a href="adventures/index.htm" id="gl3" class="glink" onmouseover="ehandler(event,menuitem3);">Adventures</a>
     <a href="proposal/index.htm" id="gl4" class="glink" onmouseover="ehandler(event,menuitem4);">Proposal</a>
     <a href="wedding/index.htm" id="gl5" class="glink" onmouseover="ehandler(event,menuitem5);">Wedding</a>
     <a href="photos/index.htm" id="gl6" class="glink" onmouseover="ehandler(event,menuitem6);">Photos</a>      
  <a href="guestbook.htm" id="gl7" class="glink" onmouseover="ehandler(event,menuitem7);">Guestbook</a>
   </div>
   <!--end globalLinks-->
   <form id="search" action="">
     <input name="searchFor" type="text" size="10">
     <a href="">search</a>
   </form>
 </div>
 <!-- end globalNav -->
 <div id="subglobal1" class="subglobalNav">
   <a href="weblog/index.htm">Greg's Blog</a>
 </div>
 <div id="subglobal2" class="subglobalNav">
   <a href="loft/index.htm">Our Chicago Loft</a>
 </div>
 <div id="subglobal3" class="subglobalNav">
   <a href="adventures/index.htm">Adventures</a> | <a href="adventures/london2">London II</a> | <a href="adventures/bikedrive">Bike the Drive
    </a> | <a href="adventures/paris">Paris
   </a> | <a href="adventures/london">London</a> | <a href="adventures/legoland">LegoLand</a> | <a href="adventures/hawaii">Hawaii</a>
 </div>
 <div id="subglobal4" class="subglobalNav">
   <a href="proposal/index.htm">Greg's Marriage Proposal</a> | <a href="proposal/photos">Photos</a>
 </div>
 <div id="subglobal5" class="subglobalNav">
   <a href="wedding/index.htm">Our Wedding</a> | <a href="wedding/rehearsal">Rehearsal</a> | <a href="wedding/herstory">Her
   Story</a> | <a href="wedding/hisstory">His Story</a> | <a href="wedding/ourstory">Our Story</a> | <a href="wedding/famfriends">Family &
   Friends Photos</a> | <a href="wedding/video">Videos</a>
 </div>
 <div id="subglobal6" class="subglobalNav">
   <a href="photos/family">Family</a> | <a href="photos/friends">Friends</a>
 | <a href="photos/misc">Miscellaneous</a>
 </div>
 <div id="subglobal7" class="subglobalNav">
   <a href="guestbook.htm">View the Guestbook</a> | <a href="addguest.htm">Sign the Guestbook</a>
 </div>
</div>
<!-- end masthead -->
<div id="pagecell1">
 <!--pagecell1-->
 <img alt="" src="tl_curve_white.gif" height="6" width="6" id="tl"> <img alt="" src="tr_curve_white.gif" height="6" width="6" id="tr">

 <div id="pageName">
   <h2>Toon-Time.com</h2>
   
 </div>
 
 <!-- START PAGE NAV -->
 <div id="pageNav">
   <div id="sectionLinks">
     <a href="weblog">Blog</a> <a href="loft">Loft</a> <a href="adventures">Adventures
     </a> <a href="proposal">Proposal</a> <a href="wedding">Wedding</a>
  <a href="photos">Photos</a> <a href="guestbook.htm">Guestbook</a>
   </div>

    <!-- ************ MOBLOG *********** -->
    <div class="moblog" align="center">
 <h3>MOBLOG</h3>  
       <script language="javascript" type="text/javascript" src="http://toon-time.textamerica.com/mypage.asp"></script>
    <a href="http://toon-time.textamerica.com"><strong>Click to see more Photos</strong></a>    </div>
    <!-- ************ MOBLOG END ************ -->
   
[B]    <!-- ************ CALENDAR *********** -->
    <div class="calendar" align="center">
 <?php include ("http://www.toon-time.com/weblog/calendar.php"); ?>
    </div>
    <!-- ************ CALENDAR END ************ -->[/B]    <div class="relatedLinks">
     <h3>Everyday Links</h3>
     <a href="http://www.bu.edu/athletics">Go BU!</a> <a href="http://www.westoverschool.org">Westover</a> <a href="http://www.wankinsong.com">Mike Barret
     </a> <a href="http://www.campwashington.org">Camp Washington</a> <a href="http://www.dailyfreepress.com">Daily Free Press</a>
  <a href="http://www.juicynote.com">Stiles' Website</a> <a href="http://www.tivocommunity.com">Tivo Community</a>
  <a href="http://www.textamerica.com">Textamerica.com</a> <a href="http://www.uscollegehockey.com/">USCHO.com</a>
   </div>

 </div>
 <div id="content">
   <!-- ********** MAIN SECTION STARTS HERE ************* -->

[B]<!-- ************ BLOG *********** -->

<?php
include('/weblog/content.php');
?>

<!-- ************ BLOG END ************ -->[/B]

   <div class="story">
     <table width="100%" border="1" cellpadding="5" cellspacing="0" summary="">
       <tr valign="top">
         <td align="center" class="storyLeft"> <p>
         <a href="loft/index.htm" class="capsule">Loft</a> <a href="loft/index.htm"><img src="loft/slides/loft_9.JPG" width="100" height="100" border="0" align="left"></a>Pictures of our home in the Windy City.  We bought the loft in June of 2002.<a href="loft/index.htm"> [more] </a></p></td>
         <td align="center"> <p>
         <a href="adventures/index.htm" class="capsule">Adventures</a> <img src="adventures/bikedrive/slides/bikedrive_9.JPG" width="123" height="90" align="left">Where in the World are Claire and Greg?  What are they up to now?  We had to use our miles to go somewhere. <a href="adventures/index.htm">[more] </a></p></td>
       </tr>
       <tr valign="top">
         <td class="storyLeft"> <p align="center">
         <a href="proposal/index.htm" class="capsule">Proposal</a> <a href="proposal/index.htm"><img src="proposal/photos/slides/proposal_22.jpg" width="123" height="90" border="0" align="left"></a>How did Greg do it?  Where did he ask the big question?  Was he nervous (you bet!)? Was Claire surprised?  All theses questions answered and more.<a href="proposal/index.htm"> [more]</a> </p></td>
         <td align="center"> <p>
         <a href="wedding/index.htm" class="capsule">Wedding</a> <a href="wedding/index.htm"><img src="wedding/small/clairegregclose_small.jpg" width="94" height="122" border="0" align="left"></a>Read about the days events from Claire's perspective and Greg's perspective leading up to the ceremony.  Watch video of the parts of the ceremony and the Best Man and Maid of Honor toasts.  Then see all the pictures.   We would like to personally thank all of our family and friends who came and made our wedding a very special day. <a href="wedding/index.htm">[more] </a></p>
         </td>
       </tr>
       <tr valign="top">
         <td align="center" class="storyLeft"> <p>
         <a href="photos/index.htm" class="capsule">Photos</a> See pictures of Greg and Claire's families, friends, and other miscellanous pictures. <a href="photos/index.htm">[more]</a> </p></td>
         <td align="center"> <p>
         <a href="weblog/index.htm" class="capsule">Blog</a> Daily entries (probably not).  Weekly entries (good chance).  Monthly (you bet).  You'll just have to follow the link and find out. <a href="weblog/index.htm">[more]</a>          </p></td>
       </tr>
     </table>
   </div>
 </div>
  <div id="siteInfo">    
    <div align="center"><a href="mailto:greg%20at%20toon-time.com">Email Greg</a> | <a href="mailto:ccoffey77%20at%20hotmail.com">Email
     Claire</a> | ©2003 - 2004 Toon-Time.com </div>
 </div>
</div>
<!--end pagecell1-->
<br>
<script type="text/javascript">
   <!--
     var menuitem1 = new menu(7,1,"hidden");
     var menuitem2 = new menu(7,2,"hidden");
     var menuitem3 = new menu(7,3,"hidden");
     var menuitem4 = new menu(7,4,"hidden");
     var menuitem5 = new menu(7,5,"hidden");
     var menuitem6 = new menu(7,6,"hidden");
     var menuitem7 = new menu(7,7,"hidden");
   // -->
   </script>
</body>
</html>
charle97
CODE
<?php include ("http://www.toon-time.com/weblog/calendar.php");?>

CODE
<?php include('/weblog/content.php');?>


your includes should be absolute server paths. the paths should look similar to your local site path and local archive path in the weblog config.
maddy
The PHP code shouldn't be visible in the page like that. Are you sure your server is setup to parse the pages for PHP code?
toon-time
Charle,

I took the absolute path off my MT configuration page and still no luck. Here is the code with the absolute path...

CODE
<div class="calendar" align="center">
 <?php include ('/www/t/toontime/htdocs/weblog/calendar.php'); ?>
    </div>


and

CODE
<?php
include("/www/t/toontime/htdocs/weblog/content.php");
?>


any other ideas?
toon-time
It should be set up to parse PHP code. If it's not, do you have any other suggestions on how I can do this without using php.
charle97
i see that you're still using .htm extension:

http://www.toon-time.com/index.htm

unless you have a htaccess directive to have .htm files to parse as php files, you should rename your index.htm file to index.php:


http://www.toon-time.com/index.php
toon-time
Charle,

smile.gif Yippie... that did it. Thanks for your patience and help

-Greg
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.