Help me in this work

Discussion in 'PHP' started by balasun, Feb 28, 2008.

  1. #1
    Hello!


    I want to concatenate PHP variables with JavaScript. But it does not work;

    My code is as follows:
    <?php
    
    $name3 = "http://a1708.g.akamai.net/7/1708/110/AH0632217021784/www.shopnbc.com/images/linkshare_banners/logos/shopnbc_125x125.gif";
    echo '<script type="text/javascript">
    seqslides[0]=["$name3", http://www.dynamicdrive.com"]
    </script>';
    
    
    ?>
    Code (markup):
    Help me to concatenate above $name3 variable with javascript. Pls
     
    balasun, Feb 28, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Because the string you're echoing is between single quotes, and variables won't be parsed between single quotes. Use double quotes, or do:
    
    echo '<script>... "' . $name3 . '" ...</script>';
    
    PHP:
     
    nico_swd, Feb 29, 2008 IP