Calling PHP Using Java

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
lazerbri
Forum Newbie
Posts: 15
Joined: Sat Dec 27, 2003 8:17 am

Calling PHP Using Java

Post 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
peni
Forum Commoner
Posts: 34
Joined: Thu Nov 18, 2004 1:15 pm

Post 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');";
?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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]
peni
Forum Commoner
Posts: 34
Joined: Thu Nov 18, 2004 1:15 pm

Post by peni »

i fear he's speaking about (live) counters or sth. like that :)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

header("Content-type: text/javascript");

Needed?
Post Reply