0

I have been looking at SO posts for hours trying to figure this out. I would like to be able to change my src in a js script using a dynamically created session variable.

$source = $_SESSION['amz'];echo $source;

echo's mws like it is supposed to. Now I am trying to get it into my script:

$a = ?><script type="text/javascript" src="buyback'<?php  echo $source; ?>'.js"></script>

I keep getting the following error:

PHP Parse error:  syntax error, unexpected ';' in /chroot/home/bookcell/bookcellaronline.com/html/testbcos/buyback/buybackmws.php on line 12

Line 12 is the $a line. Is this the correct start at least? Am I just missing something very basic?? I do have session_start() at the beginning of the page.

EDIT: I pass $a into the header of the html page:

<script type="text/javascript" src="../js/jquery_idleTimeout.js"></script>
<?php echo $a; ?>
Jim
  • 1,315
  • 4
  • 17
  • 45

2 Answers2

4

try like this-

echo $a = "<script type='text/javascript' src='buyback$source.js'></script>";

Suresh Kamrushi
  • 15,627
  • 13
  • 75
  • 90
0

What you want is

?><script type="text/javascript" src="buyback'<?php  echo $source; ?>'.js"></script>

the $a = is messing things up

hendr1x
  • 1,470
  • 1
  • 14
  • 23