How to call external php script from html? [message #172902] |
Fri, 11 March 2011 13:51 |
astral
Messages: 14 Registered: February 2011
Karma: 0
|
Junior Member |
|
|
How to call external php file from html page? Renaming page from .html to
..php not suitable due many reasons. Modifying .htaccess file to make the PHP
executable on the .html pages also not suitable. Calling PHP script from an
external javascript not work:
<script type="text/javascript"
src="http://www.domain.com/file.php"></script>
Calling from Iframe work, but its too ugly, I need specify width/height for
iframe, whereas php script need display html output without iframe
limitations.
<iframe src="http://www.domain.com/file.php" width="600"
height="300"></iframe>
I there some other method?
|
|
|
Re: How to call external php script from html? [message #172903 is a reply to message #172902] |
Fri, 11 March 2011 14:15 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
astral wrote:
> How to call external php file from html page? Renaming page from .html
> to .php not suitable due many reasons. Modifying .htaccess file to make
> the PHP executable on the .html pages also not suitable. Calling PHP
> script from an external javascript not work:
> <script type="text/javascript"
> src="http://www.domain.com/file.php"></script>
> Calling from Iframe work, but its too ugly, I need specify width/height
> for iframe, whereas php script need display html output without iframe
> limitations.
> <iframe src="http://www.domain.com/file.php" width="600"
> height="300"></iframe>
>
> I there some other method?
>
The web SERVER needs to know that it must hand the page over to a a php
interpreter rather than sending it as a load of source code.
Unless you reconfigure the web server, you are screwed.
But it seems you want to call php on a different machine that supports it.
Why not redirect the whole page to that server?
If I-frames don't work there is - gasp - plain frames...
|
|
|
|
|
|
Re: How to call external php script from html? [message #172907 is a reply to message #172902] |
Fri, 11 March 2011 14:47 |
Erwin Moller
Messages: 228 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/11/2011 2:51 PM, astral wrote:
> How to call external php file from html page? Renaming page from .html
> to .php not suitable due many reasons. Modifying .htaccess file to make
> the PHP executable on the .html pages also not suitable. Calling PHP
> script from an external javascript not work:
> <script type="text/javascript"
> src="http://www.domain.com/file.php"></script>
> Calling from Iframe work, but its too ugly, I need specify width/height
> for iframe, whereas php script need display html output without iframe
> limitations.
> <iframe src="http://www.domain.com/file.php" width="600"
> height="300"></iframe>
>
> I there some other method?
>
Hi,
If you just want to call a PHP script every time your HTML page is
requested, you could do something like:
[HTML page]
<img src="http://www.example.com/yourphpscript.php">
That way that script is called exactly 1 time for each time the HTML
page is requested.
Alternatively use JavaScript to fetch an image, but that will fail of
course if JavaScript is turned off.
Pay attention to aggressive caching strategies by the browser to make
sure it is called every time.
(Maybe let the PHP script return a valid 1x1 image with appropriate
headers.)
Regards,
Erwin Moller
--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
|
|
|
Re: How to call external php script from html? [message #172908 is a reply to message #172907] |
Fri, 11 March 2011 15:05 |
astral
Messages: 14 Registered: February 2011
Karma: 0
|
Junior Member |
|
|
"Erwin Moller"
<Since_humans_read_this_I_am_spammed_too_much(at)spamyourself(dot)com> wrote in
message news:4d7a35f5$0$41102$e4fe514c(at)news(dot)xs4all(dot)nl...
> On 3/11/2011 2:51 PM, astral wrote:
>> How to call external php file from html page? Renaming page from .html
>> to .php not suitable due many reasons. Modifying .htaccess file to make
>> the PHP executable on the .html pages also not suitable. Calling PHP
>> script from an external javascript not work:
>> <script type="text/javascript"
>> src="http://www.domain.com/file.php"></script>
>> Calling from Iframe work, but its too ugly, I need specify width/height
>> for iframe, whereas php script need display html output without iframe
>> limitations.
>> <iframe src="http://www.domain.com/file.php" width="600"
>> height="300"></iframe>
>>
>> I there some other method?
>>
>
> Hi,
>
> If you just want to call a PHP script every time your HTML page is
> requested, you could do something like:
> [HTML page]
> <img src="http://www.example.com/yourphpscript.php">
>
> That way that script is called exactly 1 time for each time the HTML page
> is requested.
>
> Alternatively use JavaScript to fetch an image, but that will fail of
> course if JavaScript is turned off.
>
> Pay attention to aggressive caching strategies by the browser to make sure
> it is called every time.
> (Maybe let the PHP script return a valid 1x1 image with appropriate
> headers.)
>
> Regards,
> Erwin Moller
>
> --
> "That which can be asserted without evidence, can be dismissed without
> evidence."
> -- Christopher Hitchens
--------------------
I use cURL php script to extract html content from remote site and display
it on my html page, so need execute this php script from my html page.
Can you clarify about fetching an image with Javascript method?
Regards,
astral
|
|
|
Re: How to call external php script from html? [message #172909 is a reply to message #172902] |
Fri, 11 March 2011 15:17 |
Captain Paralytic
Messages: 204 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On Mar 11, 1:51 pm, "astral" <ast...@news.eternal-september.org>
wrote:
> How to call external php file from html page? Renaming page from .html to
> .php not suitable due many reasons. Modifying .htaccess file to make the PHP
> executable on the .html pages also not suitable. Calling PHP script from an
> external javascript not work:
> <script type="text/javascript"
> src="http://www.domain.com/file.php"></script>
> Calling from Iframe work, but its too ugly, I need specify width/height for
> iframe, whereas php script need display html output without iframe
> limitations.
> <iframe src="http://www.domain.com/file.php" width="600"
> height="300"></iframe>
>
> I there some other method?
Assuming an apache server, use a rewrite rule to have the "page name"
displayed as .html whilst executing a php file in the background.
A "page" does not have a "name" except that which is shown in the
browser. Many php or indeed other files may be used to create what is
seen as a "page" in a browser.
|
|
|
|
|
Re: How to call external php script from html? [message #172912 is a reply to message #172910] |
Fri, 11 March 2011 16:00 |
Erwin Moller
Messages: 228 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/11/2011 4:35 PM, Doug Miller wrote:
> In article<ilddn7$uie$1(at)news(dot)eternal-september(dot)org>, "astral"<astral(at)news(dot)eternal-september(dot)org> wrote:
>
>> I use cURL php script to extract html content from remote site and display
>> it on my html page, so need execute this php script from my html page.
>
> So in other words, you're asking us to help you violate someone else's
> copyright, by stealing his site content and presenting it as your own.
>
> Bugger off.
Well Dough, we don't know that, or do we?
Personally, I am not against "stealing" content at all, assuming the OP
gives credit to the real source.
(And many authors are happy to be quoted/referenced/etc).
But just in case you are right, I await the OP's response.
Regards,
Erwin Moller
--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
|
|
|
Re: How to call external php script from html? [message #172913 is a reply to message #172912] |
Fri, 11 March 2011 16:15 |
astral
Messages: 14 Registered: February 2011
Karma: 0
|
Junior Member |
|
|
"Erwin Moller"
<Since_humans_read_this_I_am_spammed_too_much(at)spamyourself(dot)com> wrote in
message news:4d7a4734$0$41102$e4fe514c(at)news(dot)xs4all(dot)nl...
> On 3/11/2011 4:35 PM, Doug Miller wrote:
>> In article<ilddn7$uie$1(at)news(dot)eternal-september(dot)org>,
>> "astral"<astral(at)news(dot)eternal-september(dot)org> wrote:
>>
>>> I use cURL php script to extract html content from remote site and
>>> display
>>> it on my html page, so need execute this php script from my html page.
>>
>> So in other words, you're asking us to help you violate someone else's
>> copyright, by stealing his site content and presenting it as your own.
>>
>> Bugger off.
>
> Well Dough, we don't know that, or do we?
> Personally, I am not against "stealing" content at all, assuming the OP
> gives credit to the real source.
> (And many authors are happy to be quoted/referenced/etc).
>
> But just in case you are right, I await the OP's response.
>
> Regards,
> Erwin Moller
>
> --
> "That which can be asserted without evidence, can be dismissed without
> evidence."
> -- Christopher Hitchens
--------------------------
This *allowed* by resource owner, just to promote their products and
service, no any problems at all. Consider it as RSS feed, if you like(almost
same).
|
|
|
Re: How to call external php script from html? [message #172914 is a reply to message #172913] |
Fri, 11 March 2011 16:59 |
Erwin Moller
Messages: 228 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/11/2011 5:15 PM, astral wrote:
>
> "Erwin Moller"
> <Since_humans_read_this_I_am_spammed_too_much(at)spamyourself(dot)com> wrote in
> message news:4d7a4734$0$41102$e4fe514c(at)news(dot)xs4all(dot)nl...
>> On 3/11/2011 4:35 PM, Doug Miller wrote:
>>> In article<ilddn7$uie$1(at)news(dot)eternal-september(dot)org>,
>>> "astral"<astral(at)news(dot)eternal-september(dot)org> wrote:
>>>
>>>> I use cURL php script to extract html content from remote site and
>>>> display
>>>> it on my html page, so need execute this php script from my html page.
>>>
>>> So in other words, you're asking us to help you violate someone else's
>>> copyright, by stealing his site content and presenting it as your own.
>>>
>>> Bugger off.
>>
>> Well Dough, we don't know that, or do we?
>> Personally, I am not against "stealing" content at all, assuming the
>> OP gives credit to the real source.
>> (And many authors are happy to be quoted/referenced/etc).
>>
>> But just in case you are right, I await the OP's response.
>>
>> Regards,
>> Erwin Moller
>>
>> --
>> "That which can be asserted without evidence, can be dismissed without
>> evidence."
>> -- Christopher Hitchens
> --------------------------
>
> This *allowed* by resource owner, just to promote their products and
> service, no any problems at all. Consider it as RSS feed, if you
> like(almost same).
Works for me. :-)
And I don't feel like policing other people anyway.
Here is an example using JavaScript.
I would advise you to add some anti-caching approach like adding the
number of milliseconds since Unix Epoch (I added that in my example).
So try something like this:
<script type="text/javascript">
var myPHPScript = "http://www.example.com/myScript.php";
var milliSecSinceUE = (new Date()).getTime();
var myFakeImage = new Image();
myFakeImage.src = myFakeImage+"?nocache="+milliSecSinceUE;
</script>
In case your PHPscript had data in the URL already, eg:
http://www.example.com/myScript.php?article=34
You must change the ? in a &.
Also, I am polluting the global namespace with all the vars, some maybe
it's better to put it in a function if you care.
Regards,
Erwin Moller
--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
|
|
|
Re: How to call external php script from html? [message #172916 is a reply to message #172912] |
Fri, 11 March 2011 17:27 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/11/2011 11:00 AM, Erwin Moller wrote:
> On 3/11/2011 4:35 PM, Doug Miller wrote:
>> In article<ilddn7$uie$1(at)news(dot)eternal-september(dot)org>,
>> "astral"<astral(at)news(dot)eternal-september(dot)org> wrote:
>>
>>> I use cURL php script to extract html content from remote site and
>>> display
>>> it on my html page, so need execute this php script from my html page.
>>
>> So in other words, you're asking us to help you violate someone else's
>> copyright, by stealing his site content and presenting it as your own.
>>
>> Bugger off.
>
> Well Dough, we don't know that, or do we?
> Personally, I am not against "stealing" content at all, assuming the OP
> gives credit to the real source.
> (And many authors are happy to be quoted/referenced/etc).
>
> But just in case you are right, I await the OP's response.
>
> Regards,
> Erwin Moller
>
Giving credit is not enough, Erwin. You need permission to do it -
whether it is a web page, an RSS feed or anything else.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: How to call external php script from html? [message #172917 is a reply to message #172913] |
Fri, 11 March 2011 17:29 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/11/2011 11:15 AM, astral wrote:
>
> "Erwin Moller"
> <Since_humans_read_this_I_am_spammed_too_much(at)spamyourself(dot)com> wrote in
> message news:4d7a4734$0$41102$e4fe514c(at)news(dot)xs4all(dot)nl...
>> On 3/11/2011 4:35 PM, Doug Miller wrote:
>>> In article<ilddn7$uie$1(at)news(dot)eternal-september(dot)org>,
>>> "astral"<astral(at)news(dot)eternal-september(dot)org> wrote:
>>>
>>>> I use cURL php script to extract html content from remote site and
>>>> display
>>>> it on my html page, so need execute this php script from my html page.
>>>
>>> So in other words, you're asking us to help you violate someone else's
>>> copyright, by stealing his site content and presenting it as your own.
>>>
>>> Bugger off.
>>
>> Well Dough, we don't know that, or do we?
>> Personally, I am not against "stealing" content at all, assuming the
>> OP gives credit to the real source.
>> (And many authors are happy to be quoted/referenced/etc).
>>
>> But just in case you are right, I await the OP's response.
>>
>> Regards,
>> Erwin Moller
>>
>> --
>> "That which can be asserted without evidence, can be dismissed without
>> evidence."
>> -- Christopher Hitchens
> --------------------------
>
> This *allowed* by resource owner, just to promote their products and
> service, no any problems at all. Consider it as RSS feed, if you
> like(almost same).
Well, if they allow it, I would expect them to make the data available
for you and others to use without having to scrape a web page. I would
suggest you ask them about it - it would be much easier than trying to
parse a page and have to change your code every time they change the page.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: How to call external php script from html? [message #172918 is a reply to message #172917] |
Fri, 11 March 2011 18:23 |
astral
Messages: 14 Registered: February 2011
Karma: 0
|
Junior Member |
|
|
"Jerry Stuckle" <jstucklex(at)attglobal(dot)net> wrote in message
news:ildm57$2n2$2(at)news(dot)eternal-september(dot)org...
> On 3/11/2011 11:15 AM, astral wrote:
>>
>> "Erwin Moller"
>> <Since_humans_read_this_I_am_spammed_too_much(at)spamyourself(dot)com> wrote in
>> message news:4d7a4734$0$41102$e4fe514c(at)news(dot)xs4all(dot)nl...
>>> On 3/11/2011 4:35 PM, Doug Miller wrote:
>>>> In article<ilddn7$uie$1(at)news(dot)eternal-september(dot)org>,
>>>> "astral"<astral(at)news(dot)eternal-september(dot)org> wrote:
>>>>
>>>> > I use cURL php script to extract html content from remote site and
>>>> > display
>>>> > it on my html page, so need execute this php script from my html page.
>>>>
>>>> So in other words, you're asking us to help you violate someone else's
>>>> copyright, by stealing his site content and presenting it as your own.
>>>>
>>>> Bugger off.
>>>
>>> Well Dough, we don't know that, or do we?
>>> Personally, I am not against "stealing" content at all, assuming the
>>> OP gives credit to the real source.
>>> (And many authors are happy to be quoted/referenced/etc).
>>>
>>> But just in case you are right, I await the OP's response.
>>>
>>> Regards,
>>> Erwin Moller
>>>
>>> --
>>> "That which can be asserted without evidence, can be dismissed without
>>> evidence."
>>> -- Christopher Hitchens
>> --------------------------
>>
>> This *allowed* by resource owner, just to promote their products and
>> service, no any problems at all. Consider it as RSS feed, if you
>> like(almost same).
>
> Well, if they allow it, I would expect them to make the data available for
> you and others to use without having to scrape a web page. I would
> suggest you ask them about it - it would be much easier than trying to
> parse a page and have to change your code every time they change the page.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex(at)attglobal(dot)net
> ==================
--------------
allowed, I can use RSS however, I can also convert any page to RSS feed with
online services, but this will have a different look, they will not doing
design for me, also consider creating huge table with multiple cells filled
with data and specs: it easier scrap this table and display it.
thanks.
|
|
|
Re: How to call external php script from html? [message #172920 is a reply to message #172914] |
Fri, 11 March 2011 21:24 |
astral
Messages: 14 Registered: February 2011
Karma: 0
|
Junior Member |
|
|
"Erwin Moller"
<Since_humans_read_this_I_am_spammed_too_much(at)spamyourself(dot)com> wrote in
message news:4d7a54f7$0$81478$e4fe514c(at)news(dot)xs4all(dot)nl...
> On 3/11/2011 5:15 PM, astral wrote:
>>
>> "Erwin Moller"
>> <Since_humans_read_this_I_am_spammed_too_much(at)spamyourself(dot)com> wrote in
>> message news:4d7a4734$0$41102$e4fe514c(at)news(dot)xs4all(dot)nl...
>>> On 3/11/2011 4:35 PM, Doug Miller wrote:
>>>> In article<ilddn7$uie$1(at)news(dot)eternal-september(dot)org>,
>>>> "astral"<astral(at)news(dot)eternal-september(dot)org> wrote:
>>>>
>>>> > I use cURL php script to extract html content from remote site and
>>>> > display
>>>> > it on my html page, so need execute this php script from my html
page.
>>>>
>>>> So in other words, you're asking us to help you violate someone else's
>>>> copyright, by stealing his site content and presenting it as your own.
>>>>
>>>> Bugger off.
>>>
>>> Well Dough, we don't know that, or do we?
>>> Personally, I am not against "stealing" content at all, assuming the
>>> OP gives credit to the real source.
>>> (And many authors are happy to be quoted/referenced/etc).
>>>
>>> But just in case you are right, I await the OP's response.
>>>
>>> Regards,
>>> Erwin Moller
>>>
>>> --
>>> "That which can be asserted without evidence, can be dismissed without
>>> evidence."
>>> -- Christopher Hitchens
>> --------------------------
>>
>> This *allowed* by resource owner, just to promote their products and
>> service, no any problems at all. Consider it as RSS feed, if you
>> like(almost same).
>
>
> Works for me. :-)
>
> And I don't feel like policing other people anyway.
>
> Here is an example using JavaScript.
> I would advise you to add some anti-caching approach like adding the
> number of milliseconds since Unix Epoch (I added that in my example).
>
> So try something like this:
>
> <script type="text/javascript">
> var myPHPScript = "http://www.example.com/myScript.php";
> var milliSecSinceUE = (new Date()).getTime();
> var myFakeImage = new Image();
> myFakeImage.src = myFakeImage+"?nocache="+milliSecSinceUE;
> </script>
>
> In case your PHPscript had data in the URL already, eg:
> http://www.example.com/myScript.php?article=34
>
> You must change the ? in a &.
> Also, I am polluting the global namespace with all the vars, some maybe
> it's better to put it in a function if you care.
>
> Regards,
> Erwin Moller
>
-------------------
Thank you for the help, Erwin. I tried script, but it not working for me.
Server log show info that "File not found":
File not found [/hsphere/local/home/domain/domain.com/eng/4ar/[object
HTMLImageElement]]
Hosting support said that this error definitely related to my javascript.
Thanks,
astral
|
|
|
Re: How to call external php script from html? [message #172971 is a reply to message #172920] |
Mon, 14 March 2011 08:39 |
Erwin Moller
Messages: 228 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/11/2011 10:24 PM, astral wrote:
>
> "Erwin Moller"
> <Since_humans_read_this_I_am_spammed_too_much(at)spamyourself(dot)com> wrote in
> message news:4d7a54f7$0$81478$e4fe514c(at)news(dot)xs4all(dot)nl...
>> On 3/11/2011 5:15 PM, astral wrote:
>>>
>>> "Erwin Moller"
>>> <Since_humans_read_this_I_am_spammed_too_much(at)spamyourself(dot)com> wrote in
>>> message news:4d7a4734$0$41102$e4fe514c(at)news(dot)xs4all(dot)nl...
>>>> On 3/11/2011 4:35 PM, Doug Miller wrote:
>>>> > In article<ilddn7$uie$1(at)news(dot)eternal-september(dot)org>,
>>>> > "astral"<astral(at)news(dot)eternal-september(dot)org> wrote:
>>>> >
>>>> >> I use cURL php script to extract html content from remote site and
>>>> >> display
>>>> >> it on my html page, so need execute this php script from my html
> page.
>>>> >
>>>> > So in other words, you're asking us to help you violate someone else's
>>>> > copyright, by stealing his site content and presenting it as your own.
>>>> >
>>>> > Bugger off.
>>>>
>>>> Well Dough, we don't know that, or do we?
>>>> Personally, I am not against "stealing" content at all, assuming the
>>>> OP gives credit to the real source.
>>>> (And many authors are happy to be quoted/referenced/etc).
>>>>
>>>> But just in case you are right, I await the OP's response.
>>>>
>>>> Regards,
>>>> Erwin Moller
>>>>
>>>> --
>>>> "That which can be asserted without evidence, can be dismissed without
>>>> evidence."
>>>> -- Christopher Hitchens
>>> --------------------------
>>>
>>> This *allowed* by resource owner, just to promote their products and
>>> service, no any problems at all. Consider it as RSS feed, if you
>>> like(almost same).
>>
>>
>> Works for me. :-)
>>
>> And I don't feel like policing other people anyway.
>>
>> Here is an example using JavaScript.
>> I would advise you to add some anti-caching approach like adding the
>> number of milliseconds since Unix Epoch (I added that in my example).
>>
>> So try something like this:
>>
>> <script type="text/javascript">
>> var myPHPScript = "http://www.example.com/myScript.php";
>> var milliSecSinceUE = (new Date()).getTime();
>> var myFakeImage = new Image();
>> myFakeImage.src = myFakeImage+"?nocache="+milliSecSinceUE;
>> </script>
>>
>> In case your PHPscript had data in the URL already, eg:
>> http://www.example.com/myScript.php?article=34
>>
>> You must change the ? in a&.
>> Also, I am polluting the global namespace with all the vars, some maybe
>> it's better to put it in a function if you care.
>>
>> Regards,
>> Erwin Moller
>>
> -------------------
>
> Thank you for the help, Erwin. I tried script, but it not working for me.
> Server log show info that "File not found":
>
> File not found [/hsphere/local/home/domain/domain.com/eng/4ar/[object
> HTMLImageElement]]
>
> Hosting support said that this error definitely related to my javascript.
>
> Thanks,
> astral
>
Hi Astral,
That is because my code was not tested. ;-)
He is a better version:
<script type="text/javascript">
var myPHPScript = "http://www.example.com/myScript.php";
var milliSecSinceUE = (new Date()).getTime();
var myFakeImage = new Image();
myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
</script>
(The last line was wrong.)
Hope that works for you.
Regards,
Erwin Moller
--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
|
|
|
Re: How to call external php script from html? [message #172986 is a reply to message #172971] |
Mon, 14 March 2011 22:01 |
astral
Messages: 14 Registered: February 2011
Karma: 0
|
Junior Member |
|
|
"Erwin Moller" wrote:
>>> Here is an example using JavaScript.
>>> I would advise you to add some anti-caching approach like adding the
>>> number of milliseconds since Unix Epoch (I added that in my example).
>>> So try something like this:
>>> <script type="text/javascript">
>>> var myPHPScript = "http://www.example.com/myScript.php";
>>> var milliSecSinceUE = (new Date()).getTime();
>>> var myFakeImage = new Image();
>>> myFakeImage.src = myFakeImage+"?nocache="+milliSecSinceUE;
>>> </script>
>>> In case your PHPscript had data in the URL already, eg:
>>> http://www.example.com/myScript.php?article=34
>>> You must change the ? in a&.
>>> Also, I am polluting the global namespace with all the vars, some maybe
>>> it's better to put it in a function if you care.
>>> Regards,
>>> Erwin Moller
>> -------------------
>> Thank you for the help, Erwin. I tried script, but it not working for
me.
>> Server log show info that "File not found":
>> File not found [/hsphere/local/home/domain/domain.com/eng/4ar/[object
>> HTMLImageElement]]
>> Hosting support said that this error definitely related to my
javascript.
>> Thanks,
>> astral
> Hi Astral,
>
> That is because my code was not tested. ;-)
>
> He is a better version:
>
> <script type="text/javascript">
> var myPHPScript = "http://www.example.com/myScript.php";
> var milliSecSinceUE = (new Date()).getTime();
> var myFakeImage = new Image();
> myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
> </script>
>
> (The last line was wrong.)
>
> Hope that works for you.
>
> Regards,
> Erwin Moller
>
Hi,
it's not working also.
astral
|
|
|
Re: How to call external php script from html? [message #172987 is a reply to message #172986] |
Mon, 14 March 2011 23:19 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/14/2011 6:01 PM, astral wrote:
> "Erwin Moller" wrote:
>
>>>> Here is an example using JavaScript.
>>>> I would advise you to add some anti-caching approach like adding the
>>>> number of milliseconds since Unix Epoch (I added that in my example).
>
>>>> So try something like this:
>
>>>> <script type="text/javascript">
>>>> var myPHPScript = "http://www.example.com/myScript.php";
>>>> var milliSecSinceUE = (new Date()).getTime();
>>>> var myFakeImage = new Image();
>>>> myFakeImage.src = myFakeImage+"?nocache="+milliSecSinceUE;
>>>> </script>
>
>>>> In case your PHPscript had data in the URL already, eg:
>>>> http://www.example.com/myScript.php?article=34
>>>> You must change the ? in a&.
>>>> Also, I am polluting the global namespace with all the vars, some maybe
>>>> it's better to put it in a function if you care.
>
>>>> Regards,
>>>> Erwin Moller
>
>>> -------------------
>
>>> Thank you for the help, Erwin. I tried script, but it not working for
> me.
>>> Server log show info that "File not found":
>
>>> File not found [/hsphere/local/home/domain/domain.com/eng/4ar/[object
>>> HTMLImageElement]]
>
>>> Hosting support said that this error definitely related to my
> javascript.
>
>>> Thanks,
>>> astral
>
>
>> Hi Astral,
>>
>> That is because my code was not tested. ;-)
>>
>> He is a better version:
>>
>> <script type="text/javascript">
>> var myPHPScript = "http://www.example.com/myScript.php";
>> var milliSecSinceUE = (new Date()).getTime();
>> var myFakeImage = new Image();
>> myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
>> </script>
>>
>> (The last line was wrong.)
>>
>> Hope that works for you.
>>
>> Regards,
>> Erwin Moller
>>
>
> Hi,
>
> it's not working also.
>
>
> astral
>
That's because there are problems in his script. If you want a
javascript solution (which is not the best), ask in a javascript newsgroup.
The best way to call a PHP file is from a .php file. If you don't want
to change the file extension (i.e. due to bookmarks other users have - a
very valid consideration), change your Apache configuration to redirect
example.html to example.php. More info in alt.apache.configuration.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: How to call external php script from html? [message #172988 is a reply to message #172971] |
Mon, 14 March 2011 23:21 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/14/2011 4:39 AM, Erwin Moller wrote:
> On 3/11/2011 10:24 PM, astral wrote:
>>
>> "Erwin Moller"
>> <Since_humans_read_this_I_am_spammed_too_much(at)spamyourself(dot)com> wrote in
>> message news:4d7a54f7$0$81478$e4fe514c(at)news(dot)xs4all(dot)nl...
>>> On 3/11/2011 5:15 PM, astral wrote:
>>>>
>>>> "Erwin Moller"
>>>> <Since_humans_read_this_I_am_spammed_too_much(at)spamyourself(dot)com>
>>>> wrote in
>>>> message news:4d7a4734$0$41102$e4fe514c(at)news(dot)xs4all(dot)nl...
>>>> > On 3/11/2011 4:35 PM, Doug Miller wrote:
>>>> >> In article<ilddn7$uie$1(at)news(dot)eternal-september(dot)org>,
>>>> >> "astral"<astral(at)news(dot)eternal-september(dot)org> wrote:
>>>> >>
>>>> >>> I use cURL php script to extract html content from remote site and
>>>> >>> display
>>>> >>> it on my html page, so need execute this php script from my html
>> page.
>>>> >>
>>>> >> So in other words, you're asking us to help you violate someone
>>>> >> else's
>>>> >> copyright, by stealing his site content and presenting it as your
>>>> >> own.
>>>> >>
>>>> >> Bugger off.
>>>> >
>>>> > Well Dough, we don't know that, or do we?
>>>> > Personally, I am not against "stealing" content at all, assuming the
>>>> > OP gives credit to the real source.
>>>> > (And many authors are happy to be quoted/referenced/etc).
>>>> >
>>>> > But just in case you are right, I await the OP's response.
>>>> >
>>>> > Regards,
>>>> > Erwin Moller
>>>> >
>>>> > --
>>>> > "That which can be asserted without evidence, can be dismissed without
>>>> > evidence."
>>>> > -- Christopher Hitchens
>>>> --------------------------
>>>>
>>>> This *allowed* by resource owner, just to promote their products and
>>>> service, no any problems at all. Consider it as RSS feed, if you
>>>> like(almost same).
>>>
>>>
>>> Works for me. :-)
>>>
>>> And I don't feel like policing other people anyway.
>>>
>>> Here is an example using JavaScript.
>>> I would advise you to add some anti-caching approach like adding the
>>> number of milliseconds since Unix Epoch (I added that in my example).
>>>
>>> So try something like this:
>>>
>>> <script type="text/javascript">
>>> var myPHPScript = "http://www.example.com/myScript.php";
>>> var milliSecSinceUE = (new Date()).getTime();
>>> var myFakeImage = new Image();
>>> myFakeImage.src = myFakeImage+"?nocache="+milliSecSinceUE;
>>> </script>
>>>
>>> In case your PHPscript had data in the URL already, eg:
>>> http://www.example.com/myScript.php?article=34
>>>
>>> You must change the ? in a&.
>>> Also, I am polluting the global namespace with all the vars, some maybe
>>> it's better to put it in a function if you care.
>>>
>>> Regards,
>>> Erwin Moller
>>>
>> -------------------
>>
>> Thank you for the help, Erwin. I tried script, but it not working for me.
>> Server log show info that "File not found":
>>
>> File not found [/hsphere/local/home/domain/domain.com/eng/4ar/[object
>> HTMLImageElement]]
>>
>> Hosting support said that this error definitely related to my javascript.
>>
>> Thanks,
>> astral
>>
>
> Hi Astral,
>
> That is because my code was not tested. ;-)
>
> He is a better version:
>
> <script type="text/javascript">
> var myPHPScript = "http://www.example.com/myScript.php";
> var milliSecSinceUE = (new Date()).getTime();
> var myFakeImage = new Image();
> myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
> </script>
>
> (The last line was wrong.)
>
> Hope that works for you.
>
> Regards,
> Erwin Moller
>
>
Which is still not calling a PHP file from an html file - rather is is
using javascript (which may be disabled) to try to do something which
can more easily (and reliably) be done other ways.
Such as changing the Apache configuration to redirect the .html file to
a .php file and processing the .php file.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: How to call external php script from html? [message #172991 is a reply to message #172986] |
Tue, 15 March 2011 07:33 |
Erwin Moller
Messages: 228 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/14/2011 11:01 PM, astral wrote:
> "Erwin Moller" wrote:
>
>>>> Here is an example using JavaScript.
>>>> I would advise you to add some anti-caching approach like adding the
>>>> number of milliseconds since Unix Epoch (I added that in my example).
>
>>>> So try something like this:
>
>>>> <script type="text/javascript">
>>>> var myPHPScript = "http://www.example.com/myScript.php";
>>>> var milliSecSinceUE = (new Date()).getTime();
>>>> var myFakeImage = new Image();
>>>> myFakeImage.src = myFakeImage+"?nocache="+milliSecSinceUE;
>>>> </script>
>
>>>> In case your PHPscript had data in the URL already, eg:
>>>> http://www.example.com/myScript.php?article=34
>>>> You must change the ? in a&.
>>>> Also, I am polluting the global namespace with all the vars, some maybe
>>>> it's better to put it in a function if you care.
>
>>>> Regards,
>>>> Erwin Moller
>
>>> -------------------
>
>>> Thank you for the help, Erwin. I tried script, but it not working for
> me.
>>> Server log show info that "File not found":
>
>>> File not found [/hsphere/local/home/domain/domain.com/eng/4ar/[object
>>> HTMLImageElement]]
>
>>> Hosting support said that this error definitely related to my
> javascript.
>
>>> Thanks,
>>> astral
>
>
>> Hi Astral,
>>
>> That is because my code was not tested. ;-)
>>
>> He is a better version:
>>
>> <script type="text/javascript">
>> var myPHPScript = "http://www.example.com/myScript.php";
>> var milliSecSinceUE = (new Date()).getTime();
>> var myFakeImage = new Image();
>> myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
>> </script>
>>
>> (The last line was wrong.)
>>
>> Hope that works for you.
>>
>> Regards,
>> Erwin Moller
>>
>
> Hi,
>
> it's not working also.
>
It is working. It is an ancient trick.
Add an alert to it so see what page is called.
You DID change http://www.example.org/myScript.php into something
sensible I presume??
<script type="text/javascript">
var myPHPScript = "http://www.example.org/myScript.php";
var milliSecSinceUE = (new Date()).getTime();
var myFakeImage = new Image();
alert (myPHPScript +"?nocache="+milliSecSinceUE);
myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
</script>
Regards,
Erwin Moller
>
> astral
>
--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
|
|
|
|
Re: How to call external php script from html? [message #172993 is a reply to message #172992] |
Tue, 15 March 2011 11:24 |
Erwin Moller
Messages: 228 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/15/2011 12:14 PM, astral wrote:
> "Erwin Moller" wrote:
>
>>> Hi,
>
>>> it's not working also.
>
>
>> It is working. It is an ancient trick.
>
>> Add an alert to it so see what page is called.
>> You DID change http://www.example.org/myScript.php into something
>> sensible I presume??
>
>
>> <script type="text/javascript">
>> var myPHPScript = "http://www.example.org/myScript.php";
>> var milliSecSinceUE = (new Date()).getTime();
>> var myFakeImage = new Image();
>> alert (myPHPScript +"?nocache="+milliSecSinceUE);
>> myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
>> </script>
>
>
>> Regards,
>> Erwin Moller
> .............................
>
>
> Hi,
>
> sure, I used correct path in my test.
> Alert says http://www.site.com/test.php?nocache=1300186777680
>
> so it called script URL.
Hi Astral,
Then what exactly isn't working?
(Assuming you are using Apache, and know where your accesslog is and
have sufficient rights) you can check in your accesslogs if the script
is called with something like:
tail -n 100 access_log | grep test.php
to see if the request arrived.
Regards,
Erwin Moller
>
> Regards,
> astral
--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
|
|
|
Re: How to call external php script from html? [message #172994 is a reply to message #172993] |
Tue, 15 March 2011 12:43 |
astral
Messages: 14 Registered: February 2011
Karma: 0
|
Junior Member |
|
|
"Erwin Moller" wrote:
>>
>>>> Hi,
>>
>>>> it's not working also.
>>
>>
>>> It is working. It is an ancient trick.
>>
>>> Add an alert to it so see what page is called.
>>> You DID change http://www.example.org/myScript.php into something
>>> sensible I presume??
>>
>>
>>> <script type="text/javascript">
>>> var myPHPScript = "http://www.example.org/myScript.php";
>>> var milliSecSinceUE = (new Date()).getTime();
>>> var myFakeImage = new Image();
>>> alert (myPHPScript +"?nocache="+milliSecSinceUE);
>>> myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
>>> </script>
>>
>>
>>> Regards,
>>> Erwin Moller
>> .............................
>> Hi,
>> sure, I used correct path in my test.
>> Alert says http://www.site.com/test.php?nocache=1300186777680
>> so it called script URL.
> Hi Astral,
> Then what exactly isn't working?
> (Assuming you are using Apache, and know where your accesslog is and have
> sufficient rights) you can check in your accesslogs if the script is
> called with something like:
> tail -n 100 access_log | grep test.php
> to see if the request arrived.
> Regards,
> Erwin Moller
.............................
Hi,
script don't ecxhoes any output in page. I didn't find errors related to
script in access log. Perhaps this method to call script isn't supported?
Regards,
astral
|
|
|
Re: How to call external php script from html? [message #172995 is a reply to message #172994] |
Tue, 15 March 2011 12:48 |
Erwin Moller
Messages: 228 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/15/2011 1:43 PM, astral wrote:
>
> "Erwin Moller" wrote:
>>>
>>>> > Hi,
>>>
>>>> > it's not working also.
>>>
>>>
>>>> It is working. It is an ancient trick.
>>>
>>>> Add an alert to it so see what page is called.
>>>> You DID change http://www.example.org/myScript.php into something
>>>> sensible I presume??
>>>
>>>
>>>> <script type="text/javascript">
>>>> var myPHPScript = "http://www.example.org/myScript.php";
>>>> var milliSecSinceUE = (new Date()).getTime();
>>>> var myFakeImage = new Image();
>>>> alert (myPHPScript +"?nocache="+milliSecSinceUE);
>>>> myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
>>>> </script>
>>>
>>>
>>>> Regards,
>>>> Erwin Moller
>>> .............................
>
>
>>> Hi,
>
>>> sure, I used correct path in my test.
>>> Alert says http://www.site.com/test.php?nocache=1300186777680
>
>>> so it called script URL.
>
>> Hi Astral,
>
>> Then what exactly isn't working?
>
>> (Assuming you are using Apache, and know where your accesslog is and
>> have sufficient rights) you can check in your accesslogs if the script
>> is called with something like:
>
>> tail -n 100 access_log | grep test.php
>
>> to see if the request arrived.
>
>> Regards,
>> Erwin Moller
>
> ............................
>
> Hi,
>
> script don't ecxhoes any output in page. I didn't find errors related to
> script in access log. Perhaps this method to call script isn't supported?
You want the output of the PHP script to appear on your page?
That was totally unclear to me.
You'll need XMLHTTPRequest for that.
Not PHP.
Try a javascript newsgroup: --> comp.lang.javascript
Or for a quick introduction (that is not 100% correct):
http://www.w3schools.com/ajax/default.asp
Good luck.
Regards,
Erwin Moller
>
> Regards,
> astral
--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
|
|
|
Re: How to call external php script from html? [message #172996 is a reply to message #172995] |
Tue, 15 March 2011 13:04 |
astral
Messages: 14 Registered: February 2011
Karma: 0
|
Junior Member |
|
|
"Erwin Moller"
<Since_humans_read_this_I_am_spammed_too_much(at)spamyourself(dot)com> wrote in
message news:4d7f6034$0$81474$e4fe514c(at)news(dot)xs4all(dot)nl...
> On 3/15/2011 1:43 PM, astral wrote:
>>
>> "Erwin Moller" wrote:
>>>>
>>>> >> Hi,
>>>>
>>>> >> it's not working also.
>>>>
>>>>
>>>> > It is working. It is an ancient trick.
>>>>
>>>> > Add an alert to it so see what page is called.
>>>> > You DID change http://www.example.org/myScript.php into something
>>>> > sensible I presume??
>>>>
>>>>
>>>> > <script type="text/javascript">
>>>> > var myPHPScript = "http://www.example.org/myScript.php";
>>>> > var milliSecSinceUE = (new Date()).getTime();
>>>> > var myFakeImage = new Image();
>>>> > alert (myPHPScript +"?nocache="+milliSecSinceUE);
>>>> > myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
>>>> > </script>
>>>>
>>>>
>>>> > Regards,
>>>> > Erwin Moller
>>>> .............................
>>
>>
>>>> Hi,
>>
>>>> sure, I used correct path in my test.
>>>> Alert says http://www.site.com/test.php?nocache=1300186777680
>>
>>>> so it called script URL.
>>
>>> Hi Astral,
>>
>>> Then what exactly isn't working?
>>
>>> (Assuming you are using Apache, and know where your accesslog is and
>>> have sufficient rights) you can check in your accesslogs if the script
>>> is called with something like:
>>
>>> tail -n 100 access_log | grep test.php
>>
>>> to see if the request arrived.
>>
>>> Regards,
>>> Erwin Moller
>>
>> ............................
>>
>> Hi,
>>
>> script don't ecxhoes any output in page. I didn't find errors related to
>> script in access log. Perhaps this method to call script isn't supported?
>
> You want the output of the PHP script to appear on your page?
> That was totally unclear to me.
>
> You'll need XMLHTTPRequest for that.
> Not PHP.
>
> Try a javascript newsgroup: --> comp.lang.javascript
>
> Or for a quick introduction (that is not 100% correct):
> http://www.w3schools.com/ajax/default.asp
>
> Good luck.
>
> Regards,
> Erwin Moller
......................
No, I mean script parse html and should return results, not PHP script
appear on page.
Regards,
astral
|
|
|
Re: How to call external php script from html? [message #172997 is a reply to message #172996] |
Tue, 15 March 2011 13:11 |
Erwin Moller
Messages: 228 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/15/2011 2:04 PM, astral wrote:
>
> "Erwin Moller"
> <Since_humans_read_this_I_am_spammed_too_much(at)spamyourself(dot)com> wrote in
> message news:4d7f6034$0$81474$e4fe514c(at)news(dot)xs4all(dot)nl...
>> On 3/15/2011 1:43 PM, astral wrote:
>>>
>>> "Erwin Moller" wrote:
>>>> >
>>>> >>> Hi,
>>>> >
>>>> >>> it's not working also.
>>>> >
>>>> >
>>>> >> It is working. It is an ancient trick.
>>>> >
>>>> >> Add an alert to it so see what page is called.
>>>> >> You DID change http://www.example.org/myScript.php into something
>>>> >> sensible I presume??
>>>> >
>>>> >
>>>> >> <script type="text/javascript">
>>>> >> var myPHPScript = "http://www.example.org/myScript.php";
>>>> >> var milliSecSinceUE = (new Date()).getTime();
>>>> >> var myFakeImage = new Image();
>>>> >> alert (myPHPScript +"?nocache="+milliSecSinceUE);
>>>> >> myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
>>>> >> </script>
>>>> >
>>>> >
>>>> >> Regards,
>>>> >> Erwin Moller
>>>> > .............................
>>>
>>>
>>>> > Hi,
>>>
>>>> > sure, I used correct path in my test.
>>>> > Alert says http://www.site.com/test.php?nocache=1300186777680
>>>
>>>> > so it called script URL.
>>>
>>>> Hi Astral,
>>>
>>>> Then what exactly isn't working?
>>>
>>>> (Assuming you are using Apache, and know where your accesslog is and
>>>> have sufficient rights) you can check in your accesslogs if the script
>>>> is called with something like:
>>>
>>>> tail -n 100 access_log | grep test.php
>>>
>>>> to see if the request arrived.
>>>
>>>> Regards,
>>>> Erwin Moller
>>>
>>> ............................
>>>
>>> Hi,
>>>
>>> script don't ecxhoes any output in page. I didn't find errors related to
>>> script in access log. Perhaps this method to call script isn't
>>> supported?
>>
>> You want the output of the PHP script to appear on your page?
>> That was totally unclear to me.
>>
>> You'll need XMLHTTPRequest for that.
>> Not PHP.
>>
>> Try a javascript newsgroup: --> comp.lang.javascript
>>
>> Or for a quick introduction (that is not 100% correct):
>> http://www.w3schools.com/ajax/default.asp
>>
>> Good luck.
>>
>> Regards,
>> Erwin Moller
> .....................
>
> No, I mean script parse html and should return results, not PHP script
> appear on page.
>
> Regards,
> astral
Could you please write down *very* clearly what it is you want?
What should the PHP script do?
What should the clients browser do?
etc.
Thanks,
Erwin Moller
--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
|
|
|
Re: How to call external php script from html? [message #172998 is a reply to message #172997] |
Tue, 15 March 2011 13:57 |
astral
Messages: 14 Registered: February 2011
Karma: 0
|
Junior Member |
|
|
"Erwin Moller" wrote:
>>>> >>>> Hi,
>>>> >>
>>>> >>>> it's not working also.
>>>> >>
>>>> >>
>>>> >>> It is working. It is an ancient trick.
>>>> >>
>>>> >>> Add an alert to it so see what page is called.
>>>> >>> You DID change http://www.example.org/myScript.php into something
>>>> >>> sensible I presume??
>>>> >>
>>>> >>
>>>> >>> <script type="text/javascript">
>>>> >>> var myPHPScript = "http://www.example.org/myScript.php";
>>>> >>> var milliSecSinceUE = (new Date()).getTime();
>>>> >>> var myFakeImage = new Image();
>>>> >>> alert (myPHPScript +"?nocache="+milliSecSinceUE);
>>>> >>> myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
>>>> >>> </script>
>>>> >>
>>>> >>
>>>> >>> Regards,
>>>> >>> Erwin Moller
>>>> >> .............................
>>>>
>>>>
>>>> >> Hi,
>>>>
>>>> >> sure, I used correct path in my test.
>>>> >> Alert says http://www.site.com/test.php?nocache=1300186777680
>>>>
>>>> >> so it called script URL.
>>>>
>>>> > Hi Astral,
>>>>
>>>> > Then what exactly isn't working?
>>>>
>>>> > (Assuming you are using Apache, and know where your accesslog is and
>>>> > have sufficient rights) you can check in your accesslogs if the script
>>>> > is called with something like:
>>>>
>>>> > tail -n 100 access_log | grep test.php
>>>>
>>>> > to see if the request arrived.
>>>>
>>>> > Regards,
>>>> > Erwin Moller
>>>>
>>>> ............................
>>>>
>>>> Hi,
>>>>
>>>> script don't ecxhoes any output in page. I didn't find errors related
>>>> to
>>>> script in access log. Perhaps this method to call script isn't
>>>> supported?
>>>
>>> You want the output of the PHP script to appear on your page?
>>> That was totally unclear to me.
>>>
>>> You'll need XMLHTTPRequest for that.
>>> Not PHP.
>>>
>>> Try a javascript newsgroup: --> comp.lang.javascript
>>>
>>> Or for a quick introduction (that is not 100% correct):
>>> http://www.w3schools.com/ajax/default.asp
>>>
>>> Good luck.
>>>
>>> Regards,
>>> Erwin Moller
>> .....................
>>
>> No, I mean script parse html and should return results, not PHP script
>> appear on page.
>>
>> Regards,
>> astral
>
> Could you please write down *very* clearly what it is you want?
> What should the PHP script do?
> What should the clients browser do?
> etc.
-----------
Hi,
well, the php script is a curl script that fetches and displays the content
of the external site (url defined in code) and should return parsed data
(echo $html) to the calling page inside a <div> tag. Thus when the request
data is returned to the calling page it contains the content of the external
site inside some div. PHP script itself works fine, so looking for way to
call it directly from the html page.
Regards,
|
|
|
Re: How to call external php script from html? [message #173000 is a reply to message #172998] |
Tue, 15 March 2011 14:59 |
Erwin Moller
Messages: 228 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 3/15/2011 2:57 PM, astral wrote:
> "Erwin Moller" wrote:
>
>>>> >>>>> Hi,
>>>> >>>
>>>> >>>>> it's not working also.
>>>> >>>
>>>> >>>
>>>> >>>> It is working. It is an ancient trick.
>>>> >>>
>>>> >>>> Add an alert to it so see what page is called.
>>>> >>>> You DID change http://www.example.org/myScript.php into something
>>>> >>>> sensible I presume??
>>>> >>>
>>>> >>>
>>>> >>>> <script type="text/javascript">
>>>> >>>> var myPHPScript = "http://www.example.org/myScript.php";
>>>> >>>> var milliSecSinceUE = (new Date()).getTime();
>>>> >>>> var myFakeImage = new Image();
>>>> >>>> alert (myPHPScript +"?nocache="+milliSecSinceUE);
>>>> >>>> myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
>>>> >>>> </script>
>>>> >>>
>>>> >>>
>>>> >>>> Regards,
>>>> >>>> Erwin Moller
>>>> >>> .............................
>>>> >
>>>> >
>>>> >>> Hi,
>>>> >
>>>> >>> sure, I used correct path in my test.
>>>> >>> Alert says http://www.site.com/test.php?nocache=1300186777680
>>>> >
>>>> >>> so it called script URL.
>>>> >
>>>> >> Hi Astral,
>>>> >
>>>> >> Then what exactly isn't working?
>>>> >
>>>> >> (Assuming you are using Apache, and know where your accesslog is and
>>>> >> have sufficient rights) you can check in your accesslogs if the
>>>> >> script
>>>> >> is called with something like:
>>>> >
>>>> >> tail -n 100 access_log | grep test.php
>>>> >
>>>> >> to see if the request arrived.
>>>> >
>>>> >> Regards,
>>>> >> Erwin Moller
>>>> >
>>>> > ............................
>>>> >
>>>> > Hi,
>>>> >
>>>> > script don't ecxhoes any output in page. I didn't find errors
>>>> > related to
>>>> > script in access log. Perhaps this method to call script isn't
>>>> > supported?
>>>>
>>>> You want the output of the PHP script to appear on your page?
>>>> That was totally unclear to me.
>>>>
>>>> You'll need XMLHTTPRequest for that.
>>>> Not PHP.
>>>>
>>>> Try a javascript newsgroup: --> comp.lang.javascript
>>>>
>>>> Or for a quick introduction (that is not 100% correct):
>>>> http://www.w3schools.com/ajax/default.asp
>>>>
>>>> Good luck.
>>>>
>>>> Regards,
>>>> Erwin Moller
>>> .....................
>>>
>>> No, I mean script parse html and should return results, not PHP script
>>> appear on page.
>>>
>>> Regards,
>>> astral
>>
>> Could you please write down *very* clearly what it is you want?
>> What should the PHP script do?
>> What should the clients browser do?
>> etc.
> -----------
>
> Hi,
>
> well, the php script is a curl script that fetches and displays the
> content of the external site (url defined in code) and should return
> parsed data (echo $html) to the calling page inside a <div> tag. Thus
> when the request data is returned to the calling page it contains the
> content of the external site inside some div. PHP script itself works
> fine, so looking for way to call it directly from the html page.
>
> Regards,
Hi,
Use XMLHTTPRequest for that (Also known as AJAX).
Start by reading through the tutorial:
http://www.w3schools.com/ajax/default.asp
From here on I suggest you finish it in comp.lang.javascript.
This has clearly nothing to do with PHP anymore (which is working fine
as you claim).
One last question, if you don't mind:
I noticed a guy named Corvet in comp.lang.javascript asking the same
questions and posting the code I posted to you, even the first one with
a mistake in it.
Why are you astral here, and Corvet over there?
Regards,
Erwin Moller
--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
|
|
|
Re: How to call external php script from html? [message #173398 is a reply to message #172998] |
Thu, 07 April 2011 17:08 |
Tobiah
Messages: 30 Registered: April 2011
Karma: 0
|
Member |
|
|
> Hi,
>
> well, the php script is a curl script that fetches and displays the
> content of the external site (url defined in code) and should return
> parsed data (echo $html) to the calling page inside a <div> tag. Thus
> when the request data is returned to the calling page it contains the
> content of the external site inside some div. PHP script itself works
> fine, so looking for way to call it directly from the html page.
>
> Regards,
Maybe you should just load the php script into an <iframe>.
Toby
|
|
|