Placing my LOAD RECORDS in a include file

7 posts by 3 authors in: Forums > CMS Builder
Last Post: December 22, 2014   (RSS)

Is this possible?  If so, how do I do this? I would like to place all of my load records in of location so I do not need to place them on every page.  thx/

  /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

By claire - December 16, 2014 - edited: December 16, 2014

Hi there

The best thing to do is just copy the code block into a separate file and then use an include statement on each page to load them, like so:

include('/assets/includes/loadRecords.php');

Make sure you get the path right, and it'll load that block of code anywhere you put this line. Do note, however, that you might get errors if you load it out of order, so make sure you put this line where the code block would normally be on that page.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

I tried that before, but was never able to get the page to load.  I all of the load records code into the loadrecords.php and always get a blank page.

-----------

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php include('/includes/loadrecords.php'); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

By rconring - December 22, 2014 - edited: December 22, 2014

Try removing the leading slash so it reads:

<?php include('includes/loadrecords.php'); ?>

I use includes extensively and they only work without the leading slash in the path.

See this http://stackoverflow.com/questions/5366225/php-include-when-a-root-forward-slash-precedes-the-included-path-like-folde

Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

By claire - December 22, 2014

Thanks Ron, I totally missed that. Go ahead and take out the leading slash before you try anything else.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

I think we have a winner!  I guess sometimes it's the simplest fix that does it.

thanks!