TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,965
  • Latest: boruko
Stats
  • Total Posts: 195,980
  • Total Topics: 21,320
  • Online today: 261
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 191
  • Total: 191

How do you Call a PHP file into a block

Started by FERNSIDEâ„¢, September 08, 2008, 09:01:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

FERNSIDEâ„¢

Howdy  peeps :)

Im in need of a little guidance/point in the right direction.
I have a php file sitting in the root of my forum, and now I want to display/call it to a center block, and this is where Im stuck.
I searched around here, and found mention of     include('path to php file');.
What else needs to be put into the block besides that?
I added that into a script block, and the box come up clear when viewed.
Im obviously missing something.

I thought I'd ask here first, before scanning the web, as it may be different because Im calling it into a block. But I wouldnt know... hence I asking here.

Thank You in advance for any and all assistance :)

Ianedres

Make a php block, then use only the include('filename.php'); to get the file.

One note: you must use relative paths in most cases (i.e. ../filename.php or similar) to traverse from where your forum script is, to where your script is stored.

If you just need to check your php script, you can store it in the forum's directory and refer to it directly without the path.

The script file will require the opening and closing tags for php, but the block does not.

FERNSIDEâ„¢

Thanks mate.
I think Im gonna put the contents of the php, into a block.
I got 2 pages worth of errors lol    ranging from 
2: include() [<a href='function.include'>function.include</a>]: Failed opening 'http://***********.com/info.php' for inclusion (include_path='.:/usr/share/php:/tmp')
File: /home/vol3/***********.com/htdocs/Themes/default/TPortal.template.php (main sub template - eval?)
Line: 1


to

Apply Filter: Only show the errors with the same message
2: include() [<a href='function.include'>function.include</a>]: URL file-access is disabled in the server configuration
File: /home/vol3/****************.com/htdocs/Themes/default/TPortal.template.php (main sub template - eval?)
Line: 1


URL file-access is disabled in the server configuration   leads me to believe its a setting my host implemented, or the  "php"  file I have is rubbish! lol
When I set the files path in the browser, I see it fine, but since it is a collaboration of JS I threw into notepad and named  "info.php" lol   Im guessing that may be a reason it still isnt showing also! lol

Ianedres

You will need to follow the logic of the php block, as it is calling for php code- and if you're going to try to implement javascript into the block, you will need to use the 'echo' statement to output the javascript to the browser.

As for the URL file access, that will be a php.ini configuration file setting for allow_url_fopen as noted here.

FERNSIDEâ„¢

Thanks mate.
When I have time, I'll read up on php.
Im still readin sloowly through the xhtml beginners guide! lol
All in time ;)

JPDeni

It looks like, from the error message, that you're using a URL in your "include" function. You do not want to use a URL. You want to use a path. They're often similar, but they're not the same thing. URLs start with "http://" while a path would likely start with "/home/username/public_html/" and so on. Or you can use a relative path, but I can never remember where they're relative to. I think the starting path for blocks is the Sources directory, so you would use


include("../file.php");


but I could be wrong on that. I always have to use trial and error to work out the path.

Or....

You could copy the whole php file, except for the first and last lines, and paste it into a php block and then you wouldn't have to worry about the path for the include.

This website is proudly hosted on Crocweb Cloud Website Hosting.