Link to home
Start Free TrialLog in
Avatar of betic
betic

asked on

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.
Avatar of Diablo84
Diablo84

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');
see: http://us2.php.net/manual/en/function.include.php

eg:

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

  </td>
 </tr>
</table>
Take note though, the file that you are including it in must also have a .php extension
Avatar of betic

ASKER

would i just use these as they are typed within the table itself. . .no other tags?
Avatar of betic

ASKER

okay, i'll try that
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.
Avatar of betic

ASKER

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?
Avatar of betic

ASKER

<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>
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'); ?>
Avatar of betic

ASKER

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
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).
Avatar of betic

ASKER

i cut them out with the editor on the server side and it's still not affecting it.
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.
Avatar of betic

ASKER

that file also shows up blank
Avatar of betic

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Diablo84
Diablo84

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of betic

ASKER

ahh, no, i have no way to do that.  That's what I was needing though.  No other ways around that then?
Not with PHP no. I have one other idea but need to check something first, il get back to you.
Avatar of betic

ASKER

thank you
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.
Avatar of betic

ASKER

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)
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
Avatar of betic

ASKER

cool, thank you for your time, you've been extremely helpful
no problem :)