Jump to content

Unable to pass php variable to Javascript


Staggan

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.