Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-08-22 11:17:31

Gallex
Member
Registered: 2006-10-08
Posts: 1,331

PHP and include....again

right now i have:

in page template:
<txp:output_form form=“kalkulaator” />

in kalkulaator form:
<code>
<txp:php>
include(‘http://www.laenukassa.ee/kalkulaator.php’);
</txp:php>
</code>

script location (loan calculator):
http://www.laenukassa.ee/kalkulaator.php

…but doesn’t work. all PHP-s in preferences are allowed. what i am missing?

Offline

#2 2007-08-22 11:32:29

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: PHP and include....again

define “doesn’t work” ;)

Offline

#3 2007-08-22 11:55:44

Gallex
Member
Registered: 2006-10-08
Posts: 1,331

Re: PHP and include....again

ruud wrote:

define “doesn’t work” ;)

p-p-p, can you explain me more specificly, i’m dumb in php?

Offline

#4 2007-08-22 12:00:38

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: PHP and include....again

You don’t need PHP for that to work (at least, when looking at the calculator page, I don’t see how PHP is used in it). You can simply copy the calculator HTML code into your template/page/article (whatever) and add the link to include the “script/calc_scripts.js” file to the HTML head section of the template/page.

Last edited by ruud (2007-08-22 12:05:10)

Offline

#5 2007-08-22 12:02:04

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,238
Website GitHub

Re: PHP and include....again

define “doesn’t work” ;)

Ruud means can you be more specific about what does not work? ;-)
For example, do a tag trace (switch to debug mode in the prefs, then check your source code).


TXP Builders – finely-crafted code, design and txp

Offline

#6 2007-08-22 12:16:07

Gallex
Member
Registered: 2006-10-08
Posts: 1,331

Re: PHP and include....again

jakob wrote:

Ruud means can you be more specific about what does not work? ;-)
For example, do a tag trace (switch to debug mode in the prefs, then check your source code).

ok, i don’t need to, but I still want to know what’s wrong and maybe later in a future i need to…

here is a tag trace, what you can read from this?
http://www.laenukassa.ee/uus/kalkulaator/

Offline

#7 2007-08-22 12:23:40

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: PHP and include....again

This is the problem: “URL file-access is disabled in the server configuration”
Solution: host the included PHP file on your own server and refer to it by server file path name instead of URL.

Offline

#8 2007-08-22 13:00:27

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,238
Website GitHub

Re: PHP and include....again

ok, i don’t need to…

Well it seems it did help :-)


TXP Builders – finely-crafted code, design and txp

Offline

#9 2007-08-22 13:28:52

Gallex
Member
Registered: 2006-10-08
Posts: 1,331

Re: PHP and include....again

ruud wrote:

This is the problem: “URL file-access is disabled in the server configuration”
Solution: host the included PHP file on your own server and refer to it by server file path name instead of URL.

my own server? you mean i have to upload it via TXP to files folder? or what “my own server”, i don’t get it?

right now the php file in root folder, TXP in subfolder /uus

Offline

#10 2007-08-22 13:52:27

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: PHP and include....again

your own server = server where your website is hosted.
Upload using FTP, put it in a folder, then include the file using the file path on your websites server.

Offline

#11 2007-08-23 10:13:11

Gallex
Member
Registered: 2006-10-08
Posts: 1,331

Re: PHP and include....again

ruud wrote:

your own server = server where your website is hosted.
Upload using FTP, put it in a folder, then include the file using the file path on your websites server.

ok, i put it into same folder where TXP has installed (kalkulaator.php was in a root folder and TXP in a subfolder “uus” before) and wrote to form:

<code>
<txp:php>
include(‘./kalkulaator.php’);
</txp:php>
</code>

but…look at this

what is wrong now?

Offline

#12 2007-08-23 10:24:20

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: PHP and include....again

Looks like a variable that wasn’t initialized properly. Try switching to ‘live’ mode instead of debug/testing. If that doesn’t help, I think you’ll have to pick up a book on PHP programming and fix the script you’re trying to include.

Offline

#13 2007-08-23 11:05:57

Gallex
Member
Registered: 2006-10-08
Posts: 1,331

Re: PHP and include....again

ruud wrote:

Looks like a variable that wasn’t initialized properly. Try switching to ‘live’ mode instead of debug/testing.

aa, sorry ;) here again

If that doesn’t help, I think you’ll have to pick up a book on PHP programming and fix the script you’re trying to include.

but here it’s working like it should be, but when i include it… :(

you still think the script is incorrect?

Offline

#14 2007-08-23 11:13:50

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: PHP and include....again

Look at the HTML source code it produces on this page
You’ll see the problem. It includes an entire HTML document (including doctype) inside another HTML page. That won’t validate. The script was written as a stand-alone script. If you want to include it, you’ll have to modify it to fit within the environment where you want to use it.

Offline

#15 2007-08-23 11:27:51

Gallex
Member
Registered: 2006-10-08
Posts: 1,331

Re: PHP and include....again

ruud wrote:

Look at the HTML source code it produces on this page
You’ll see the problem. It includes an entire HTML document (including doctype) inside another HTML page. That won’t validate. The script was written as a stand-alone script. If you want to include it, you’ll have to modify it to fit within the environment where you want to use it.

aaa, i just have to remove this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Autolaenu taotlus</title> <link rel="stylesheet" type="text/css" href="css/simple_theme.css" /> <script type="text/javascript" src="script/calc_scripts.js"></script> </head>

and put this:

<link rel="stylesheet" type="text/css" href="css/simple_theme.css" /> <script type="text/javascript" src="script/calc_scripts.js"></script>

into page head, right?

Last edited by Gallex (2007-08-23 11:29:06)

Offline

Board footer

Powered by FluxBB