The problem is that php can't do anything after the markup has already reached the client--it has to be parsed beforehand.
-james
__________________
"God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "
<SCRIPT>
function Sp()
{
<?php FUNCTION; ?>
}
</SCRIPT>
If you use:
<?php include ('somefile.php') ?>
the script will be parsed for that page, before it reaches the client.
On the otherhand, if you use:
<script type="text/javascript">document.write("<?php include ('somefile.php') ?>");</script>
the include will not be executed, but merely written to the page.
I don't know, if that answers your question, but if you explain (explicitly) what you are trying to accomplish, maybe, someone can help you with the functionality.
-james
__________________
"God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "
<SCRIPT>
function Spiro()
{
</SCRIPT>
<Script SRC=http://blabla/Some.php></Script>
<SCRIPT>
}
</SCRIPT>
Is this suposed to work!??I need something like that-a function that include a php script.
Open() do not do the job. Can anyone tell me how to fix that!?
<SCRIPT>
function Spiro()
{
</SCRIPT>
<?php include 'http://blabla/Some.php'; ?>
<SCRIPT>
}
</SCRIPT>
that is what I would do
i don't know that i've ever tried something like that, but i'm about 98% sure script tags don't work that way. the following variant of that idea should work, however:
<SCRIPT>
function Spiro() {
var phpScript = new Image();
phpScript.src = 'http://blabla/Some.php';
}
</SCRIPT>
Welll...Fci, you can't do that. .)
It's not only that the php code will be executed just like it is not inside a function...The first </SCRIPT> is closing the first <SCRIPT> and the function is not finished.
the script will be parsed for that page, before it reaches the client.
On the otherhand, if you use:
<script type="text/javascript">document.write("<?php include ('somefile.php') ?>");</script>
the include will not be executed, but merely written to the page.
I don't know, if that answers your question, but if you explain (explicitly) what you are trying to accomplish, maybe, someone can help you with the functionality.
I think, if you will better explain what you are trying to do, someone will be able to help you.
First thing you need to do is to give your pages a php extension, for any php script to work on the page.
-james
__________________
"God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "
Last edited by jamescover; 08-31-2004 at 08:52 AM..
i agree with James; we need more information. what is it that the php you're trying to call is supposed to be doing? if you're just trying to execute an arbitrary php function when a browser event fires, the method i've shown you is fine. or are you trying to get the php to print some output to the browser?
Well...It's about a script that calculates the users online. I found some dozens smilar scripts with diffrent ideas, but all of them had many disadvantages and first of all they did not show the exact number of users, but the hits of the site in the last hour or some similar relativity.
I would like when a user close the site that to be recorded at once. Soo...how else but with the onunload event?!?
When I started to realise the idea I didn't know a single function on JavaScript()...besides I already made a users online script...not that good as I would like, but good...too.
Soo...Here's the idea:
A mysql table:
Column 1: IP varchar(15)
Column 2: bigint LastAccessTime
1.The user open the page. The user's IP is recorded.
2.The user close the page and the IP should be removed from the database.
3.The user desides to refresh the page...well the onunload event is fiered and the IP is removed, but with the refreshing of the page the IP is added again.
Now what's that AccessTime you would say...
Well...what if the user just shuts its PC and there's no time for decrement...or he loose connection to the internet or whatever...
With every add the enough old records are deleted...That makes the script relativity again...but not that much...besides at every refreshing or reloading of the home page the user's IP will be added again...
And that would be all the problems...but no-just one more-the JavaScript.
On every fireing of the onunload event should be executed that php code-the deleteing of the user's IP. That's what I nead that functin for.
Onather problem is that not all the brouzers supporst JavaScript. Soo...if the increment fragment is in the same users online script it will be no problem to be executed, but the included with JavaScript will. So...that's easy...We simply put the increment fragment in a second file that is called with <SCRIPT SRC=...
Well...That would be the entire problem...More details?!??
The including of the file with that function is not the only desicion however.
We can achieve the same using JavaScript connection to the db createing a new database object...I found that out recently. But I do not prefer that way...my db username and password will be reveald. Besides I can not make it do it...I can not make the connection.
Any answers will be more than...hah...I already missed the dead line and I made that not that perffect users online script...Well...It's not something who knows how much important...But I started it and didn't like not to finishe it.