[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

Auto Load PHP script in HTML

I have an html page with tables and have installed a php bulletin board and a php calendar script the bulletin board is on an external page and runs fine, i don't, however, know how to run the calendar script within one of the tables on the html page.  I need the page to load up with the script running if possible.  Thank you.
0
betic
Asked:
betic
  • 13
  • 12
1 Solution
 
Diablo84Commented:
You sound as though you are wanting to use include to include the script within the table, eg:

include('scriptname.php');

or

require('scriptname.php');
0
 
Diablo84Commented:
see: http://us2.php.net/manual/en/function.include.php

eg:

<table>
 <tr>
  <td width="100%">
 
<?php include('scriptname.php'); ?>

  </td>
 </tr>
</table>
0
 
Diablo84Commented:
Take note though, the file that you are including it in must also have a .php extension
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
beticAuthor Commented:
would i just use these as they are typed within the table itself. . .no other tags?
0
 
beticAuthor Commented:
okay, i'll try that
0
 
Diablo84Commented:
Wherever you want the calender to appear (presuming the calender script handles the output) you would add
<?php include('scriptname.php'); ?>, then the processed output from the script will be included within the file at the point
where the php snippet was placed.
0
 
beticAuthor Commented:
here's the script as it is on my page, it's just showing up blank.  if i type the address to the php file directly it's working fine.  maybe it's something with how my table's constructed?
0
 
beticAuthor Commented:
<td width="174" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
            <!--DWLayoutTable-->
            <tr>
              <td width="3" height="1453" valign="top"><img src="Images/Long-Dashed-Line-Right.gif" width="1" height="1453"></td>
              <td width="104" valign="top"><!-- InstanceBeginEditable name="Body Right" -->

<?php include('calendar.php'); ?>

<!-- InstanceEndEditable --></td>
          </tr>
          </table></td>
0
 
Diablo84Commented:
Can you view the source of the page and see if <?php include('calendar.php'); ?> is still present or if the output from the script is there.

2 things to check

1) That file definitely has a .php extension?
2) is calendar.php in the same folder as this file?

if not you will have to do something like <?php include($_SERVER['DOCUMENT_ROOT'].'/path/to/calendar.php'); ?>
0
 
beticAuthor Commented:
it's showing up when i view the source of the page.  the calendar.php and the page that's calling it are both located in my public_html folder
0
 
Diablo84Commented:
It might be something to do with the dreamweaver templates, the PHP was color coded as a comment in dreamweaver  and i couldn't edit anything in this section or after it:

<!-- InstanceBeginEditable name="Body Right" -->

<?php include('calendar.php'); ?>

<!-- InstanceEndEditable -->

They shouldnt cause a problem at run time as they are technically just a html comment  but as the calendar output is visible in the source of the page it might be getting rendered as a comment as well. Could you possibly try it with the dreamweaver tags removed (you might have to edit it with notepad).
0
 
beticAuthor Commented:
i cut them out with the editor on the server side and it's still not affecting it.
0
 
Diablo84Commented:
ok, can you just create another file to test with, call it test.php or something and add:

<table width="100%" border="0" cellpadding="0" cellspacing="0">
 <tr>
  <td width="3" height="1453" valign="top"><img src="Images/Long-Dashed-Line-Right.gif" width="1" height="1453"></td>
  <td width="104" valign="top">
  <?php include('calendar.php'); ?>
  </td>
 </tr>
</table>

If that displays correctly then theres soemthing else in your main script causing the problem, if it doesn't then we can start narrowing down the problem.
0
 
beticAuthor Commented:
that file also shows up blank
0
 
beticAuthor Commented:
here's a link to the page in it's entirety if you want to see it, the calendar is supposed to be on the right table at the top
0
 
beticAuthor Commented:
0
 
Diablo84Commented:
ah thats the problem, in the source:

<?php include('calendar.php'); ?>

its not getting parsed because the extension is .htm

The page extension must be .php unless you have the ability to configure the server and have it parse .htm extensions
0
 
beticAuthor Commented:
ahh, no, i have no way to do that.  That's what I was needing though.  No other ways around that then?
0
 
Diablo84Commented:
Not with PHP no. I have one other idea but need to check something first, il get back to you.
0
 
beticAuthor Commented:
thank you
0
 
Diablo84Commented:
Ok, i am having configuration issues at the moment so i can't test this idea unfortuently.

You can try, instead of php includes, SSI which depends on your web server being configured for it.

<!--#include file="calendar.php" -->

If you still see that when you view the source then its not going to work. I'm not 100% sure that PHP files will be parsed using this method which is why i would have liked to have tried it first but its worth a try.
0
 
beticAuthor Commented:
i just resaved the entire page as a php file and it loads fine, that's not going to mess anything else up will it?  if so, then i can just do that (just have to remember that when updating pages with dreamweaver)
0
 
Diablo84Commented:
It should all work fine like that, remember a .php page is the same as an ordinary html page with the exception that it can contain php which will be parsed by the php engine. The only thing that might come up is if you have any other pages linked to that page you will have to change the extension in the links
0
 
beticAuthor Commented:
cool, thank you for your time, you've been extremely helpful
0
 
Diablo84Commented:
no problem :)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 13
  • 12
Tackle projects and never again get stuck behind a technical roadblock.
Join Now