little php help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fris
    Too lazy to set a custom title
    • Aug 2002
    • 55679

    #1

    little php help

    how do I declare a variable in php to use in javascript

    Code:
    function msnad_head() {
        $siteurl = get_option('siteurl');
        $url = $siteurl . '/wp-content/plugins/' . basename(dirname(__FILE__)) . '/msnad.js';
    
        print('
    <script type="text/javascript">
        var linkout="http://www.google.com";
        var maintxt = $msnad_settings['message']; //this part
        var toptext="New Instant Message:";
        var imgad="impic.jpg";
    </script>
    <script type="text/javascript" src="'.$url.'"></script>
    
        ');
    }
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.
  • sexy-frenchie
    Confirmed User
    • Mar 2008
    • 199

    #2
    Try this:

    PHP Code:
    echo '
    <script type="text/javascript">
        var linkout="http://www.google.com";
        var maintxt = "' . $msnad_settings['message'] . '";
        var toptext="New Instant Message:";
        var imgad="impic.jpg";
    </script>
    <script type="text/javascript" src="'.$url.'"></script>
    '; 
    
    I like sexy porn

    Comment

    • fris
      Too lazy to set a custom title
      • Aug 2002
      • 55679

      #3
      result is blank

      var maintxt = "";

      is its output
      Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

      Comment

      • sexy-frenchie
        Confirmed User
        • Mar 2008
        • 199

        #4
        The array $msnad_settings is not defined in your function.
        Where does its value come from?
        I like sexy porn

        Comment

        • calmlikeabomb
          Confirmed User
          • May 2004
          • 1323

          #5
          Right, $msnad_settings is out of scope.

          You'll either need to give it some kind of global scope such as assigning it to a $_SESSION variable, or pass it to your function.
          subarus.

          Comment

          • fris
            Too lazy to set a custom title
            • Aug 2002
            • 55679

            #6
            ya works now forgot to global $msnad_settings;
            Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

            Comment

            • Killswitch - BANNED FOR LIFE

              #7
              Darrrrrrrrr.

              Comment

              Working...