Page 1 of 1

Calling PHP Using Java

Posted: Sun Nov 21, 2004 9:31 am
by lazerbri
Hi
I am experimenting with calling a PHP script from a html page using a Java script. Here's what I have so far

Code: Select all

<script language="javascript" src="http://www.mysite.com/test.php"></script>
and my test.php...

Code: Select all

<?php
print  "hello";

?>
This keeps sending errors.

Other people are using this java script to call hit counter php scripts and it works fine. Anyone know why mine does not work and gives the error "Done, but with errors"?

Regards

Bri

Posted: Sun Nov 21, 2004 9:49 am
by peni
1. never say "java" to "javascript"

2. of course, there's no js-command "hello". try putting into test.php:

Code: Select all

<?php
    echo "document.write('ok');";
?>

Posted: Sun Nov 21, 2004 10:53 am
by John Cartwright
peni wrote:1. never say "java" to "javascript"

2. of course, there's no js-command "hello". try putting into test.php:

Code: Select all

<?php
    echo "document.write('ok');";
?>
As little I know about javascript this is not what he is after :P
<script language="javascript" src="http://www.mysite.com/test.php"></script>
Why even bother is javascript in the first place. You can include files in php via [php_man]include[/php_man] or [php_man]require[/php_man]

Posted: Sun Nov 21, 2004 11:02 am
by peni
i fear he's speaking about (live) counters or sth. like that :)

Posted: Sun Nov 21, 2004 11:07 am
by John Cartwright
No matter what PHP will require a refresh, therefor eliminating the logic in using PHP for 'live' counters. Better off doing it completely in javascript if this is what hes after

Posted: Sun Nov 21, 2004 4:44 pm
by Steveo31
header("Content-type: text/javascript");

Needed?