473,396 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

No output in calling HTML ?

Hi,

When I include a script in my html I don't get any output back in the
calling page.
The script is on a remote location for the html page. Example given:

myscript.php:
<?PHP
echo 'Yoohoo, here I am';
// and the rest of the script writes an entry into a tracker db so I know it
was called succesfully
?>

mypage.html:
<html>
<head>
<title>Just a page</title>
</head>
<body>
<script language = 'PHP' src =
http://www.anotherserver.com/myscript.php></script>
</body>
</html>

Any ideas how to change the behaviour ? What am I doing wrong ?
Thanks!
Pjotr
Jul 17 '05 #1
6 2330

Pjotr:

Using this style, you are asking your client (the browser) to execute
the script locally, rather than the server. This is unlikely to work.

If you want the script to execute on the server and insert output into
an HTML document, one method would be:

myscript.php:
<?php
// send some javascript...
print "document.write( 'hello!' );";
?>

mypage.html:
<html>
<head>
<title>Just a page</title>
</head>
<body>
<script language="javascript"
src="http://www.anotherserver.com/myscript.php"></script>
</body>
</html>

---
Steve

Jul 17 '05 #2
Steve wrote:
Pjotr:

Using this style, you are asking your client (the browser) to execute
the script locally, rather than the server. This is unlikely to work.

If you want the script to execute on the server and insert output into
an HTML document, one method would be:

myscript.php:
<?php
// send some javascript...
print "document.write( 'hello!' );";


mypage.html:
<html>
<head>
<title>Just a page</title>
</head>
<body>
<script language="javascript"
src="http://www.anotherserver.com/myscript.php"></script>
</body>
</html>

---
Steve


Hmmm, I don't think this is what I am after. The script definitely runs -on
the server- without a problem. I can see the entries in my database.
Besides, my counter script works like this like a charm for all my other
webpages as well. I cannot imagine I need Javascript really to get a PHP
output string back in my browser. I don't want to use J(ava)script anyway,
as I cannot be sure all clients have it enabled.
Thanks for your thoughts though! Any other ideas ?

Pjotr
Jul 17 '05 #3
> Hi,

When I include a script in my html I don't get any output back in the
calling page.
The script is on a remote location for the html page. Example given:

myscript.php:
<?PHP
echo 'Yoohoo, here I am';
// and the rest of the script writes an entry into a tracker db so I know it was called succesfully
?>

mypage.html:
<html>
<head>
<title>Just a page</title>
</head>
<body>
<script language = 'PHP' src =
http://www.anotherserver.com/myscript.php></script>
</body>
</html>

Any ideas how to change the behaviour ? What am I doing wrong ?
Thanks!
Pjotr


I don't think you can use the scr property of a <script> tag to include a
php file. The reason is that the scr property will be loaded by the browser
(not the server). So the browser load the source (that's why you see traces
in your db) but it don't do anything with it. What the browser receice is
"Yoohoo, here I am" and it doesn't mean nothing to him. So the use of the
<script> tags for embeding php code is different from javascript
(client-side script).

If you NEED to include a php file inside an html file, I would suggest you
to use a combination of javascript and php
Exemple:

myscript.php:
<?PHP
echo 'document.write(\'Yoohoo, here I am\')';
// and the rest of the script writes an entry into a tracker db so I know
it was called succesfully
?>

mypage.html:
<html>
<head>
<title>Just a page</title>
</head>
<body>
<script language = 'javascript' src =
http://www.anotherserver.com/myscript.php></script>
</body>
</html>

Dae
Jul 17 '05 #4
Hmmm, I don't think this is what I am after. The script definitely runs -on the server- without a problem. I can see the entries in my database.
Besides, my counter script works like this like a charm for all my other webpages as well. I cannot imagine I need Javascript really to get a PHP output string back in my browser. I don't want to use J(ava)script anyway, as I cannot be sure all clients have it enabled.
Thanks for your thoughts though! Any other ideas ?


Pjotr:

I expressed this badly. Using <script> in the <body> defines
client-side script. Yes, your script is called and executed on the
server, but whatever text is returned from the script is executed in
the browser using the script engine specified. Most browsers do not
have a PHP engine available.

This is the main reason why most tracker applications use an embedded
image file rather than a script. As you say, not all clients will have
javascript or will always enable it if they have it. Most clients will
respond to an <img> tag (hmmm, would Lynx fetch anything?)

An alternative if you wish to avoid javascript is to have your PHP
script return an image and call it using <img
src="http://www.myserver.com/myscript.php">, making sure of course that
you set the MIME type accordingly. Search comp.lang.php for many
previous threads on this topic.

---
Steve

Jul 17 '05 #5
Pjotr Wedersteers wrote:
<script language = 'PHP' src =
http://www.anotherserver.com/myscript.php></script> What am I doing wrong ?


Confusing PHP tags with HTML tags. There are four different
PHP start-tags, and that's not one of them.

<http://www.php.net/manual/en/language.basic-syntax.php#language.basic-syntax.phpmode>

--
Jock
Jul 17 '05 #6
Pjotr Wedersteers wrote:
<script language = 'PHP' src =
http://www.anotherserver.com/myscript.php></script>


IMHO there is no src-attribute for a PHP script.

Read http://www.php.net/manual/en/language.basic-syntax.php.

Regards,
Matthias
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Hugh Macdonald | last post by:
I'm calling a command from within a python script and I need to be able to both catch the output (stdout and stderr) from it and also have the PID (so that I can kill it) I can do one or other...
9
by: Kim | last post by:
Hi everyone, I'm writing a embeded python program, and I want to evaluate some expression by calling function: PyRun_SimpleString("print 'hello'") I don't want to output it to stdout but...
2
by: Harlin Seritt | last post by:
Hi, I am using CherryPy to make a very small Blog web app. Of course I use a textarea input on a page to get some information. Most of the time when text is entered into it, there will be...
4
by: Steven | last post by:
I'm calling a stored procedure which has an output parameter of type int. Once the stored procedure is executed, I want to check the value of the parameter in case it is null. However, when the a...
2
by: Thomas Hermann | last post by:
A newbie question: With the config mentioned in the topic, all on localhost, Win xpsp2, i created a caledar-table. The output should be a daily calendar for half a year with about 15 cols. ...
11
by: Roger Leigh | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The program listed below demonstrates the use of wcsftime() and std::time_put<wchar_t> which is a C++ wrapper around it. (I know this isn't C; but...
1
by: Garth Wells | last post by:
Using an example in the Jan 2006 release of the Enterprise Library, I came up with the code shown below to create a DAL method for returning several columns of a single row. I place the output...
3
by: ajh | last post by:
Using Ubuntu 5, Apache2 and PHP 4 I am trying display in a web browser the output from a program I wrote in C. Here is an abridged version of my code (I can post all of it later): <?php ...
13
by: Jim Langston | last post by:
I had asked this in comp.lang.c++ with out any answers that would actually work, so I'm hoping someone here may know a way. I am calling C library functions that want to output to stdout. I need...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.