emma57573 Posted October 8, 2008 Share Posted October 8, 2008 I have some code that im using on my site thats works great, I want to use the same code on my PHPBB Forum but in order to run smoothly I need to covert it to javascript. However its not working so somethings wrong with my syntax. If anyone could help that would be great. This is the working code <?PHP //script for the <BODY> area of your source code, transferring necessary user data //place this script on every page if the user is logged in !!! $tk_name = "$V3CHAT_NAME"; //<-- please set the username here $tk_user_id = "$V3CHAT_USER"; //<-- please set the user ID here $tk_gender = ""; //<-- optional (the gender of the user can be female or 'male') $tk_age = ""; //<-- optional (the age of the user e.g. '23') $tk_single = ""; //<-- optional (is the user single? 'Yes', 'no', '0' = no information) $tk_profile_url = ""; //<-- optional (url to the users profile) $tk_pic = ""; //<-- optional (url of the users picture) $tk_city = ""; //<-- optional (city where the user is located, e.g. 'Berlin') $tk_zip = ""; //<-- optional (users zip code, e.g. '92553') $tk_country = ""; //<-- optional (country where the user is located, e.g. 'Germany') //DO NOT EDIT THE FOLLOWING CODE! $tk_user_data="name:".$tk_name. ";gender:".$tk_gender. ";age:".$tk_age. ";single:".$tk_single. ";url:".$tk_profile_url. ";pic:".$tk_pic. ";city:".$tk_city. ";tk_zip:".$tk_zip. ";country:".$tk_country; //implements the js needed by the chatWatcher and to start a chat $tk_hash = md5($tk_user_id.$tk_user_data."wcwUrTFHLbpMeV9vcnSp"); $tk_js = "<script type='text/javascript' src='http://www.toksta.com/js/w/?tk_hash=" . $tk_hash . "&app_id=87879&app_user_id=".$tk_user_id."&tk_user_data=".rawurlencode($tk_user_data)."'></script>" . "<script type='text/javascript' src='http://www.toksta.com/js/tokstaIm/?tk_hash=" . $tk_hash . "&app_id=87879&app_user_id=".$tk_user_id."&tk_user_data=".rawurlencode($tk_user_data)."'></script>"; echo $tk_js; ?> This is how ive converted it for phpbb. It just comes up with a java error popup <script type='text/javascript' src='http://www.toksta.com/js/w/?tk_hash=md5("{USER_ID}". name:"{USER_NAME}"; gender:""; age:""; single:""; url:""; pic:""; city:""; tk_zip:""; country:""; ."wcwUrTFHLbpMeV9vcnSp")&app_id=87879&app_user_id="{USER_ID}"&tk_user_data=".rawurlencode( name:"{USER_NAME}"; gender:""; age:""; single:""; url:""; pic:""; city:""; tk_zip:""; country:""; )."'> </script> <script type='text/javascript' src='http://www.toksta.com/js/w/?tk_hash=md5("{USER_ID}". name:"{USER_NAME}"; gender:""; age:""; single:""; url:""; pic:""; city:""; tk_zip:""; country:""; ."wcwUrTFHLbpMeV9vcnSp")&app_id=87879&app_user_id="{USER_ID}"&tk_user_data=".rawurlencode( name:"{USER_NAME}"; gender:""; age:""; single:""; url:""; pic:""; city:""; tk_zip:""; country:""; )."'> </script> Quote Link to comment Share on other sites More sharing options...
rochakchauhan Posted October 11, 2008 Share Posted October 11, 2008 NOGO.. it wont work... to set value from PHP to javascript you need to write like this... <?php $phpVar1="Value1"; $phpVar2="Value2"; echo "<script type='text/javascript'>"; echo "var jsVar1='$phpVar1';"; echo "var jsVar2='$phpVar2';"; echo "function someFunction() { alert(jsVar1); }"; echo "</script>"; ?> This above code will give this output: <script type='text/javascript'> var jsVar1='Value1'; var jsVar2='Value2'; function someFunction(){ alert(jsVar1); } </script> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.