|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Transfering variables to php script
Hi,
The following code does not transfer variables r and u to a php script, probably syntax error. What's wrong? <script language="JavaScript" src="http://www.abcd.net/feed.php?r="+escape(document.referrer)+"u="+escape(navigator.userAgent)></script> Thanks |
|
#2
|
||||
|
||||
|
You're trying to execute script code within the script declaration. I'm not sure I understand what you're even trying to do. If you're specifying a src for a javascript, it should be a .js file and not a php file. Why don't you describe what you're trying to accomplish?
|
|
#3
|
|||
|
|||
|
Thanks. This script is from the article xml content feed revisited, by Michael Harper. It's is in the test.html. I add u and r vaiables to get the stats of the site. What I want to do is get the statitics of one site and store them in a database of another site.
|
|
#4
|
||||
|
||||
|
Aha. The issue is still that you're trying to write js code in the script invocation, and that won't work as you've got it. You can try something like the following, though:
Code:
<script language="javascript">
document.write("<script language=\"JavaScript\" src=\"http://www.abcd.net/feed.php?r=" + escape(document.referer) + "&u=" + escape(navigator.userAgent)\"></script>\n");
</script>
Use javascript to write inline javascript. Or if your page is in PHP anyway, use PHP to generate the js. There are a couple of syntax errors in your URL, which I've corrected. Namely, you've left off the ampersand before the second parameter, and you haven't closed the quote you opened for the script source. Hope this helps. Incidentally, I'm not certain this'll work -- the inline js may not parse and run on the fly. Maybe it's worth a shot, though. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Transfering variables to php script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|