php within dhtml, is that possible? | | |
hello,
in a dhtml page generated from php I want to include a file which is
in fact the body of the dhtml page. My hosting ISP does not allow SSI
but supports php includes. In the dhtml page, the generated statment
<?php include('fspecs') ?>
is ignored. I've the feeling that I'm overlooking something in the
way php is parsing dhtml (if it does). The dhtml code saved in a file
execute correctly after that...
Any hints about this?
Thanks in advance.
--
jj - Mercredi 10 Mai 2006 --- 23:14:59 | | | | re: php within dhtml, is that possible?
Jacques Jamain wrote:[color=blue]
> hello,
> in a dhtml page generated from php I want to include a file which is
> in fact the body of the dhtml page. My hosting ISP does not allow SSI
> but supports php includes. In the dhtml page, the generated statment
> <?php include('fspecs') ?>
> is ignored. I've the feeling that I'm overlooking something in the
> way php is parsing dhtml (if it does). The dhtml code saved in a file
> execute correctly after that...
> Any hints about this?
> Thanks in advance.
>[/color]
Jacques,
What do you mean "ignored"?
Have you looked at the source for the page when it gets to your browser?
Perhaps it's there and you don't see it.
Otherwise, you must be getting an error which isn't being displayed. Turn on
all errors and display them to see if there are any.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attglobal.net
================== | | | | re: php within dhtml, is that possible?
Jacques Jamain wrote:[color=blue]
> In the dhtml page, the
> generated statment <?php include('fspecs') ?>
> is ignored. I've the feeling that I'm overlooking something in the
> way php is parsing dhtml (if it does).[/color]
What do you mean, generated statement? Is 'fspecs' a file, and do you
already include it while sending the page to the browser? How do you
generate it?
The server side php can perform actions on the server, and output data to
browsers. With a few exceptions, it doesn't really care about what data,
that's your job as programmer. Sending HTML or JS is equal to sending pdf or
txt, it's just data... No checking for validity, no parsing.
PHP can't be executed on the clients machine, so if you generate <?php
include('fspecs') ?> with javascript, it's just nonsense to your browser.
So, building client side PHP code has no use, except when sending it back to
the server and eval() it, which is a huge security risk.
If it's generated on the server: echoing <?php //something ?> will not
execute it, look at eval().
If it's generated on the clients machine: look at javascipts
XHTMLhttprequest() instead.
If it's genuine PHP code on the server: what is the surrounding code, and
where does the file 'fspecs' reside?
Grtz,
--
Rik Wasmus | | | | re: php within dhtml, is that possible?
hi Jerry,
Wed, 10 May 2006 17:58:54 -0400
comp.lang.php -- Jerry Stuckle <jstucklex@attglobal.net> écrivait (wrote):[color=blue]
>Jacques Jamain wrote:[color=green]
>> hello,
>> in a dhtml page generated from php I want to include a file which is
>> in fact the body of the dhtml page. My hosting ISP does not allow SSI
>> but supports php includes. In the dhtml page, the generated statment
>> <?php include('fspecs') ?>
>> is ignored. I've the feeling that I'm overlooking something in the
>> way php is parsing dhtml (if it does). The dhtml code saved in a file
>> execute correctly after that...
>> Any hints about this?
>> Thanks in advance.
>>[/color]
>
>Jacques,
>
>What do you mean "ignored"?
>[/color]
... intended code in 'fspecs' not included ...
[color=blue]
>Have you looked at the source for the page when it gets to your browser?
>Perhaps it's there and you don't see it.
>[/color]
yes, the <?php include('fspecs') ?> statment is there, well generated
by php at server side but not processed and now it becomes obvious
to me that it cannot be processed at client side, too late...
My problem seems to be (or could be): "how to force php to work recursively"
Anyway thanks to take care...
had a good day
--
jj - Jeudi 11 Mai 2006 --- 11:16:40 | | | | re: php within dhtml, is that possible?
hi Rik,
Thu, 11 May 2006 01:49:25 +0200
comp.lang.php -- "Rik" <luiheidsgoeroe@hotmail.com> écrivait (wrote):[color=blue]
>Jacques Jamain wrote:[color=green]
>> In the dhtml page, the
>> generated statment <?php include('fspecs') ?>
>> is ignored. I've the feeling that I'm overlooking something in the
>> way php is parsing dhtml (if it does).[/color]
>
>What do you mean, generated statement? Is 'fspecs' a file, and do you
>already include it while sending the page to the browser? How do you
>generate it?
>
>The server side php can perform actions on the server, and output data to
>browsers. With a few exceptions, it doesn't really care about what data,
>that's your job as programmer. Sending HTML or JS is equal to sending pdf or
>txt, it's just data... No checking for validity, no parsing.
>[/color]
ok, I have to explain a bit more what I intend to obtain.
At server side I generate an html file to include some data obtained
from mysql, to be passed to JS. This is done by echoing the html head
and the JS directives and the data with php. It's ok, and now I have
to add the html body and I was thinking that instead of echoing all
the html directives it would be nice to include a file holding all
those directives. That's SSI, but helas my hosting isp does not support,
hence the tentative with php.
The actual question: "is recursion possible with php and if yes how?"
Hope this clarify a few my situation.
Thanks for your help and suggestions.
[color=blue]
>PHP can't be executed on the clients machine, so if you generate <?php
>include('fspecs') ?> with javascript, it's just nonsense to your browser.
>So, building client side PHP code has no use, except when sending it back to
>the server and eval() it, which is a huge security risk.
>[/color]
ok, I agree
[color=blue]
>If it's generated on the server: echoing <?php //something ?> will not
>execute it, look at eval().
>[/color]
It's the case, I've to look at this...
[color=blue]
>If it's generated on the clients machine: look at javascipts
>XHTMLhttprequest() instead.
>
>If it's genuine PHP code on the server: what is the surrounding code, and
>where does the file 'fspecs' reside?
>[/color]
this file is on the server
thanks again
Cheers
--
jj - Jeudi 11 Mai 2006 --- 11:28:57 | | | | re: php within dhtml, is that possible?
Jacques Jamain wrote:[color=blue]
> ok, I have to explain a bit more what I intend to obtain.
> At server side I generate an html file to include some data obtained
> from mysql, to be passed to JS. This is done by echoing the html
> head and the JS directives and the data with php. It's ok, and now
> I have to add the html body and I was thinking that instead of
> echoing all the html directives it would be nice to include a file
> holding all those directives. That's SSI, but helas my hosting isp
> does not support, hence the tentative with php.
> The actual question: "is recursion possible with php and if yes
> how?"[/color]
I still don't really get what you are trying to do:
You have some data retrieved from the database, and after that you want a
HTML body...
Why not just end parsing with php (?>), and write the HTML? Echoing is nog
necessary. I think I'm missing something here.
The HTML body, is it dynamic, and if so, how do you control that: php or
client side js?
Am I to understand that a simple:
include("your/desired/file.html");
does not work?
Grtz,
--
Rik Wasmus | | | | re: php within dhtml, is that possible?
Jacques Jamain wrote:[color=blue]
> hi Jerry,
> Wed, 10 May 2006 17:58:54 -0400
> comp.lang.php -- Jerry Stuckle <jstucklex@attglobal.net> écrivait (wrote):
>[color=green]
>>Jacques Jamain wrote:
>>[color=darkred]
>>> hello,
>>> in a dhtml page generated from php I want to include a file which is
>>> in fact the body of the dhtml page. My hosting ISP does not allow SSI
>>> but supports php includes. In the dhtml page, the generated statment
>>> <?php include('fspecs') ?>
>>> is ignored. I've the feeling that I'm overlooking something in the
>>> way php is parsing dhtml (if it does). The dhtml code saved in a file
>>> execute correctly after that...
>>> Any hints about this?
>>> Thanks in advance.
>>>[/color]
>>
>>Jacques,
>>
>>What do you mean "ignored"?
>>[/color]
>
> ... intended code in 'fspecs' not included ...
>
>[color=green]
>>Have you looked at the source for the page when it gets to your browser?
>>Perhaps it's there and you don't see it.
>>[/color]
>
>
> yes, the <?php include('fspecs') ?> statment is there, well generated
> by php at server side but not processed and now it becomes obvious
> to me that it cannot be processed at client side, too late...
> My problem seems to be (or could be): "how to force php to work recursively"
> Anyway thanks to take care...
> had a good day
>[/color]
No, PHP is never processed client-side. So if you're trying to add it inline,
i.e. with echo, it won't work.
Several ways you can do this. You can use a template processor. You can use
eval to execute the code (my personal least favorite). You can write it to a
temporary file then include the file. And probably several other ways.
But why generate the statement in the first place? Why not just execute the
statement instead?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attglobal.net
================== | | | | re: php within dhtml, is that possible?
Jacques Jamain wrote:[color=blue]
> hi Rik,
>
> Thu, 11 May 2006 01:49:25 +0200
> comp.lang.php -- "Rik" <luiheidsgoeroe@hotmail.com> écrivait (wrote):
>[color=green]
>>Jacques Jamain wrote:
>>[color=darkred]
>>>In the dhtml page, the
>>> generated statment <?php include('fspecs') ?>
>>> is ignored. I've the feeling that I'm overlooking something in the
>>> way php is parsing dhtml (if it does).[/color]
>>
>>What do you mean, generated statement? Is 'fspecs' a file, and do you
>>already include it while sending the page to the browser? How do you
>>generate it?
>>
>>The server side php can perform actions on the server, and output data to
>>browsers. With a few exceptions, it doesn't really care about what data,
>>that's your job as programmer. Sending HTML or JS is equal to sending pdf or
>>txt, it's just data... No checking for validity, no parsing.
>>[/color]
>
>
> ok, I have to explain a bit more what I intend to obtain.
> At server side I generate an html file to include some data obtained
> from mysql, to be passed to JS. This is done by echoing the html head
> and the JS directives and the data with php. It's ok, and now I have
> to add the html body and I was thinking that instead of echoing all
> the html directives it would be nice to include a file holding all
> those directives. That's SSI, but helas my hosting isp does not support,
> hence the tentative with php.
> The actual question: "is recursion possible with php and if yes how?"
>
> Hope this clarify a few my situation.
> Thanks for your help and suggestions.
>
>[color=green]
>>PHP can't be executed on the clients machine, so if you generate <?php
>>include('fspecs') ?> with javascript, it's just nonsense to your browser.
>>So, building client side PHP code has no use, except when sending it back to
>>the server and eval() it, which is a huge security risk.
>>[/color]
>
> ok, I agree
>
>[color=green]
>>If it's generated on the server: echoing <?php //something ?> will not
>>execute it, look at eval().
>>[/color]
>
> It's the case, I've to look at this...
>
>[color=green]
>>If it's generated on the clients machine: look at javascipts
>>XHTMLhttprequest() instead.
>>
>>If it's genuine PHP code on the server: what is the surrounding code, and
>>where does the file 'fspecs' reside?
>>[/color]
>
>
> this file is on the server
> thanks again
> Cheers[/color]
Jacques,
PHP should parse the contents of any file with a .php extension - even if it's
referenced by include(). So if you include('xyz.php') and in that file have
include('fspecs'), it should be processed just fine.
And btw - this isn't recursion.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attglobal.net
================== | | | | re: php within dhtml, is that possible?
Rik,
Thu, 11 May 2006 12:29:21 +0200
comp.lang.php -- "Rik" <luiheidsgoeroe@hotmail.com> écrivait (wrote):[color=blue]
>Jacques Jamain wrote:[color=green]
>> ok, I have to explain a bit more what I intend to obtain.
>> At server side I generate an html file to include some data obtained
>> from mysql, to be passed to JS. This is done by echoing the html
>> head and the JS directives and the data with php. It's ok, and now
>> I have to add the html body and I was thinking that instead of
>> echoing all the html directives it would be nice to include a file
>> holding all those directives. That's SSI, but helas my hosting isp
>> does not support, hence the tentative with php.
>> The actual question: "is recursion possible with php and if yes
>> how?"[/color]
>
>I still don't really get what you are trying to do:
>You have some data retrieved from the database, and after that you want a
>HTML body...
>Why not just end parsing with php (?>), and write the HTML? Echoing is nog
>necessary. I think I'm missing something here.
>
>The HTML body, is it dynamic, and if so, how do you control that: php or
>client side js?
>
>Am I to understand that a simple:
>include("your/desired/file.html");
>does not work?[/color]
well, think to a quiz. At the server the Q&A are in mysql. The client
invokes that quiz as www.mysite.com. At mysite there is an index.php
which read the db, and build a dhtml set with all the things, JS data,
JS source and html body allowing to call the JS functions presenting
the quiz to the client and handling its answers. The data, the JS and
the html body are on the server. There is no problem echoing the data
and the html head directives including the JS source. My problem is to
include the html body file using php code in the index.php.
The interesting effect is that, if I save the dhtml echoed with the
<?php include('fspecs') ?> inside at client side and then I transfer
that file as is to the server I get exactly what I want.
If SSI was enabled the method would be to echo:
<!-- #include virtual=\"fspecs\" -->
instead
am I doing something wrong?
thanks
--
jj - Jeudi 11 Mai 2006 --- 14:47:39 | | | | re: php within dhtml, is that possible?
Jacques Jamain wrote:
[color=blue]
> ... intended code in 'fspecs' not included ...[/color]
What if you replace this:
<?php include('fspecs') ?>
with this:
<?php phpinfo(); ?>
??
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact | | | | re: php within dhtml, is that possible?
What file extension does your primary page have? If your web server
isn't setup to parse .html files for php code, the code will pass
through to the client browser without any interpretation. So if on the
client-side you are seeing "<?php include('fspecs') ?>" when you view
the page source, then I suspect you need to modify your web server's
config to parse html files for php code. | | | | re: php within dhtml, is that possible?
hi,
14 May 2006 15:20:21 -0700
comp.lang.php
-- "william.clarke@gmail.com" <william.clarke@gmail.com> écrivait (wrote):[color=blue]
>What file extension does your primary page have? If your web server
>isn't setup to parse .html files for php code, the code will pass
>through to the client browser without any interpretation. So if on the
>client-side you are seeing "<?php include('fspecs') ?>" when you view
>the page source, then I suspect you need to modify your web server's
>config to parse html files for php code.
>[/color]
I can't do anything to the config of my isp server but on my test
machine, which is an apache server (all in one, client and server on
the same machine), the server is well configured to parse php
code (addtype, addoutputfilter, includes...). The problem is that if the
dhtml echoed by php contains php directives (<?php include('fspecs') ?>)
these directives are not parsed again by php... Anyway I think it's
not possible and I changed my design (if any d;-) and have set the db
ouput for JS in a file from a separate run and all the includes are made
from a static html file.
Thanks for your help.
--
jj - Lundi 15 Mai 2006 --- 22:48:17 | | | | re: php within dhtml, is that possible?
Hm..
<?php include('fspecs') ?>
And the extension? | | | | re: php within dhtml, is that possible?
hi,
15 May 2006 22:33:31 -0700
comp.lang.php -- "RainCT" <rainbow2@eurion.net> écrivait (wrote):[color=blue]
>Hm..
>
><?php include('fspecs') ?>
>
>And the extension?
>[/color]
any extension, .php .htm .shtml ...
to clarify you can cut and paste to your server the following
and thanks to the kindness of your browser about html standards
you would see what I mean...
__________________________________________________ _____________________
<?php echo ' <html><head> <title>Hello</title></head>' . "\n";
$fdhtml= 'fn.php';
$finc = 'inc.php';
if (!$handle=fopen($fdhtml,'w+')){echo "Can't open file ($dhtml)";exit;}
if (!$handle_i=fopen($finc,'w+')){echo "Can't open file ($finc)";exit;}
$htmStuff =
'<body><h1>Hello</h1></body></html>'. "\n";
$incStuff =
'<?php include(\'fn.php\') ?><body><h1>Hello</h1></body></html>'. "\n";
if (fwrite($handle, $htmStuff) === FALSE)
{ echo "Cannot write to file ($fdhtml)"; exit;}
if (fwrite($handle_i, $incStuff) === FALSE)
{ echo "Cannot write to file ($finc)"; exit;}
fclose($handle); fclose($handle_i);
$inc = "<?php include('fn.php') ?><br>...include not included<br>";
echo $inc;
echo '<br><a href=fn.php>fn</a>';
echo '<br><a href=inc.php>inc</a><br>';
?>
__________________________________________________ _____________________
This write 2 files: fn.php and inc.php, echo an approximative dhtml and
intend to include on the fly fn.php, well echoed but not processed as
indicated in the title and in the rendered html.
In the dhtml, links to fn.php and inc.php are provided.
The link to inc.php shows that the php include is working on that server
when statically invoked...
If you are too far of your server you can try this link:
<http://jjamain.free.fr/samp.php>
HTH.
--
jj - Mardi 16 Mai 2006 --- 15:01:31 | | | | re: php within dhtml, is that possible?
Jacques Jamain wrote:
[color=blue]
> $inc = "<?php include('fn.php') ?><br>...include not included<br>";
> echo $inc;[/color]
Of course it isn't included. You're sending the <?php...?> to the client.
The client can't do anything with it.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact | | | | re: php within dhtml, is that possible?
hello Toby,
Tue, 16 May 2006 15:33:09 +0100
comp.lang.php
-- Toby Inkster <usenet200605@tobyinkster.co.uk> écrivait (wrote):[color=blue]
>Jacques Jamain wrote:
>[color=green]
>> $inc = "<?php include('fn.php') ?><br>...include not included<br>";
>> echo $inc;[/color]
>
>Of course it isn't included. You're sending the <?php...?> to the client.
>The client can't do anything with it.
>[/color]
yes, I know that, but my point is (was after a bypass) "is it possible
to have a php directive like <?php include('fn.php') ?> processed on
the server within a php execution?". Now, my answer is "no, php does
not allow self recursion", but I don't want to be alone to think that
and I don't have obtained a clear answer to that question here until
now.
Thanks to take care.
--
jj - Mardi 16 Mai 2006 --- 22:31:27 | | | | re: php within dhtml, is that possible?
Jacques Jamain wrote:
[color=blue]
> yes, I know that, but my point is (was after a bypass) "is it possible
> to have a php directive like <?php include('fn.php') ?> processed on
> the server within a php execution?".[/color]
Yes it is:
Call this file "foo.php", save it to your server and visit it:
<?php
global $foocount;
$foocount++;
print "This file has been included recursively $foocount times<br>\n";
if ($foocount < 100)
include("foo.php");
?>
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact | | | | re: php within dhtml, is that possible?
hi,
Toby Inkster wrote:
[color=blue]
> Jacques Jamain wrote:
>[color=green]
> > yes, I know that, but my point is (was after a bypass) "is it possible
> > to have a php directive like <?php include('fn.php') ?> processed on
> > the server within a php execution?".[/color]
>
> Yes it is:
>
> Call this file "foo.php", save it to your server and visit it:
>
> <?php
> global $foocount;
> $foocount++;
> print "This file has been included recursively $foocount times<br>\n";
> if ($foocount < 100)
> include("foo.php");
> ?>
>
>[/color]
great and so simple... often you search for complicated methods when
it's obviously under your eyes.
Many thanks for this kind solution. |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,467 network members.
|