Welcome, Guest. Please login or register.
Did you miss your activation email?
February 12, 2012, 09:41:00 PM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
149687 Posts in 21102 Topics by 7538 Members
Latest Member: ionline
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Php includes  (Read 1007 times)
dondemaio

Offline Offline

Posts: 7


« on: September 30, 2009, 12:13:10 PM »

Hi. I'm a novice at this so advanced programmers will probably think this is an extremely stupid question. I just want to include another php file in one of my WebsiteBaker pages. So how do I put the php code in the page?

For instance, I want to insert the following code in one of my WB pages:

<?php include("http://www.uusarasota.com/inout/index.php?page=view/article/3/Lifespan-Education"); ?>

But when I insert it as Source or WSIWYG mode nothing appears on the page.

Thanks for any help you can give me.

Don
« Last Edit: September 30, 2009, 12:21:27 PM by dondemaio » Logged
pcwacht
AddOn Development
*
Online Online

Posts: 2814



WWW
« Reply #1 on: September 30, 2009, 12:20:48 PM »

You can try a code section:
make a page in it choose wysiwyg, then choose sections, then create a code section and another wysiwyg section

The code section does NOT need <?php tags!

Or have a look at droplets with wich you can do much more and easier Wink

Have fun,
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
RonK

Online Online

Posts: 81


WWW
« Reply #2 on: February 07, 2010, 11:30:07 PM »

Hi John,

I have a similair problem.

I have a page which I want to divide into four sections:
topleft, topright, bottomleft and bottomright.

I each section I want to display some information from four external or internal pages.

But as soon as I use "include(PAGES_DIRECTORY.\'topleft.php\');" in one of the cells, I see only the actual text and not the contents of page topleft.php.

You mention in your answer to dondemaio to use droplets. I use droplets on website too, but could not find a droplet that can do this.

Any ideas what I am doing wrong?


Code:

echo '
<table width="100%">
  <tr style="border-bottom: 1px solid gray;">
    <td align="center">
        <font size="+1">
        De Gereformeerde Kerk Lopik is een eigentijdse, actieve
        <br />
        gemeente midden in het groene hart van Nederland.
        </font>
        <hr align="center" size="1" color="#808080" />
    </td>
  </tr>
  <tr>
    <td>
        <table id="middlecolumns" width="100%">
          <tr>
            <td width="50%">
             include(PAGES_DIRECTORY.\'topleft.php\');
            </td>
            <td width="50%">
                rechts boven
            </td>
          </tr>
          <tr>
            <td>
                links onder
            </td>
            <td>
                rechts onder
            </td>
          </tr>
        </table>
    </td>
  </tr>
</table>
';

Logged

crnogorac081
AddOn Development
*
Offline Offline

Posts: 1680



« Reply #3 on: February 08, 2010, 12:01:47 AM »

Try this code:

Code:

echo '
<table width="100%">
  <tr style="border-bottom: 1px solid gray;">
    <td align="center">
        <font size="+1">
        De Gereformeerde Kerk Lopik is een eigentijdse, actieve
        <br />
        gemeente midden in het groene hart van Nederland.
        </font>
        <hr align="center" size="1" color="#808080" />
    </td>
  </tr>
  <tr>
    <td>
        <table id="middlecolumns" width="100%">
          <tr>
            <td width="50%">';

include(PAGES_DIRECTORY.\'topleft.php\');

echo '           </td>
            <td width="50%">
                rechts boven
            </td>
          </tr>
          <tr>
            <td>
                links onder
            </td>
            <td>
                rechts onder
            </td>
          </tr>
        </table>
    </td>
  </tr>
</table>
';
Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
RonK

Online Online

Posts: 81


WWW
« Reply #4 on: February 08, 2010, 09:45:51 AM »

Hi crnogorac081,

Thank you for your quick answer.

I should have thought about that myself.

Nevertheless, I tried the code, but both rows (topleft and topright) are blank.
This is the code I see when I look at the source:
Code:
<table width="100%">
  <tr style="border-bottom: 1px solid gray;">
    <td align="center">
        <font size="+1">
        De Gereformeerde Kerk Lopik is een eigentijdse, actieve
        <br />
        gemeente midden in het groene hart van Nederland.
        </font>
        <hr align="center" size="1" color="#808080" />
    </td>
  </tr>
  <tr>
    <td>
        <table id="middlecolumns" width="100%">
          <tr>
            <td width="50%">           </td>
            <td width="50%">            </td>
          </tr>
          <tr>
            <td>
                links onder
            </td>
            <td>
                rechts onder
            </td>
          </tr>
        </table>
    </td>
  </tr>
</table>


There is nothing (but spaces) in the two rows.
Both include pages (topleft.php and topright.php) contain only text.

It seems nothing of the included page in shown.
Logged

pcwacht
AddOn Development
*
Online Online

Posts: 2814



WWW
« Reply #5 on: February 08, 2010, 04:57:09 PM »

I think
include(PAGES_DIRECTORY.\'topleft.php\');

should be:
include(PAGES_DIRECTORY.'/topleft.php');

This only works when the file topleft.php exists in the pages directory and echos some output ofcourse.

have fun,
John
Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
crnogorac081
AddOn Development
*
Offline Offline

Posts: 1680



« Reply #6 on: February 08, 2010, 05:05:13 PM »

Yes, John is right, sorry but I didnt notice the php syntax error in code.

cheers
Logged

Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
RonK

Online Online

Posts: 81


WWW
« Reply #7 on: February 08, 2010, 08:34:10 PM »

Hi,

thanks for the reaction. I noticed the typo myself too. But still no go.
Not when topleft.php is just a WYSIWYG page, nor when the topleft.php consists of code (echo "test topleft"Wink.

I get the next error messages. I am sure topleft.php is in the path mentioned in the include statement.

Warning: include(/pages/topleft.php) [function.include]: failed to open stream: No such file or directory in U:\Webdesign\wb28\modules\code\view.php(30) : eval()'d code on line 19

Warning: include() [function.include]: Failed opening '/pages/topleft.php' for inclusion (include_path='.;C:\php5\pear') in U:\Webdesign\wb28\modules\code\view.php(30) : eval()'d code on line 19

I get the idea it is not possible the way I like to divide my page into four segments.
Logged

pcwacht
AddOn Development
*
Online Online

Posts: 2814



WWW
« Reply #8 on: February 08, 2010, 09:09:22 PM »

Code:
No such file or directory in U:\Webdesign\wb28\modules\code\view.php(30) : eval()'d code on line 19
When reading this error message, didn't you notice it can't find the file it is supposed to include?


MAKE SURE!!!!! the file exists where you think it is.
Check, double check and check again, php is simply telling you it can't find the file.


Good luck,
John

Logged

http://www.ictwacht.nl = Dutch ICT info
http://www.pcwacht.nl = My first
both still work in progress, since years.....
RonK

Online Online

Posts: 81


WWW
« Reply #9 on: February 08, 2010, 09:56:07 PM »

The file topleft.php IS in the /pages directory. That is the strange thing.

From the webroot /pages/topleft.php (which is PAGES_DIRECTORY."/topleft.php") is there.

Or do you think it is looking for topleft.php from the u:\ root ?

Hmm, I copied the pages directory to the root of drive u:, .... ad=nd the error message changed.
Now it can not find the config.php file, which is normal.

So will try to define the right path to the pages directory from the webroot.

Update:
When change the line to:
           include(WB_URL.PAGES_DIRECT ORY."/topleft.php");

the next errors appear:
Warning: include(http://localhost:8081/pages/topleft.php) [function.include]: failed to open stream: no suitable wrapper could be found in U:\Webdesign\wb28\modules\code\view.php(30) : eval()'d code on line 21

So, it seems including a complete URL path is not allowed.

Oefhh, another update  (maybe I solve this one myself wink );
Changed to line to:
            include(WB_PATH.PAGES_DIREC TORY."/topleft.php");

and get the next error:
Warning: require(../config.php) [function.require]: failed to open stream: No such file or directory in U:\Webdesign\wb28\pages\topleft.php on line 3

Fatal error: require() [function.require]: Failed opening required '../config.php' (include_path='.;C:\php5\pear') in U:\Webdesign\wb28\pages\topleft.php on line 3

Now config.php could not be found (which is in topleft.php by default by creating a page).

I still have not solved it sad
« Last Edit: February 08, 2010, 10:31:13 PM by RonK » Logged

Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!