Staggan Posted January 22, 2013 Share Posted January 22, 2013 Hello I am after some help... I am trying to pass a number of php variables to javascript variables and it is not working, instead javascript is assigning the php query to those variables... This is my code: <script type="text/javascript"> var snsUserid = "<?=$snsUID?>" ; var sns = 'Game'; var snsUsername = "<?=$snsUsername?>"; var snsAffiliateid = 1; var userLang = "<?=$userLang?>"; </script> OR <script type="text/javascript"> var snsUserid = "<? echo $snsUID; ?>" ; var sns = 'Game'; var snsUsername = "<? echo $snsUsername; ?>"; var snsAffiliateid = 1; var userLang = "<? echo $userLang; ?>"; </script> Basically the code assigns the whole string to the var rather than the php variable value Neither works Any ideas ? Thanks Link to comment https://forums.phpfreaks.com/topic/273488-unable-to-pass-php-variable-to-javascript/ Share on other sites More sharing options...
Jessica Posted January 22, 2013 Share Posted January 22, 2013 Try using full tags, not short tags. If that doesn't fix it, show us the actual output. Link to comment https://forums.phpfreaks.com/topic/273488-unable-to-pass-php-variable-to-javascript/#findComment-1407482 Share on other sites More sharing options...
Staggan Posted January 22, 2013 Author Share Posted January 22, 2013 Thanks Solved now, php on the server this was running off was not setup right, so I am told, and now it works... Thanks for the help though. Link to comment https://forums.phpfreaks.com/topic/273488-unable-to-pass-php-variable-to-javascript/#findComment-1407489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.