Results 1 to 6 of 6

Thread: How should I write this javascript in php

  1. #1
    Join Date
    Aug 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How should I write this javascript in php

    Hello, I got some problems with my php code, im trying to use a javascript to remove the "click here to activate" but I got some problems, take a look at this code, at AC_FL_RunContent( 'codebase' all the text become "bugged" because I already used one ' before. Anyways here it is:

    PHP Code:
    <?php
    $link 
    '<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
    <script src="Scripts/AC_ActiveX.js" type="text/javascript"></script>
    <script type="text/javascript">
    AC_FL_RunContent( '
    codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','100','height','100','src','click_test','quality','high','FlashVars','file=<?php echo $numb; ?>','wmode','opaque','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','click_test' ); //end AC code
    </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100" height="100">
      <param name="movie" value="click_test.swf" />
      <param name="quality" value="high" />
      <param name="FlashVars" value="file=<?php echo $numb?>" />
      <param name="wmode" value="opaque" />
      <embed src="click_test.swf" quality="high" FlashVars="<?php echo $numb?>" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="opaque" width="100" height="100"></embed>
    </object></noscript>';
    ?>
    At first I was just going to end the tag ?> and then place the javascript and then open the php tag again with <?php

    But the $link = file doesnt work then... im not sure what to do now, should I try to use " or ┤?

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You will need to escape the quotes like so:

    Code:
    <?php
    $link = '<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
    <script src="Scripts/AC_ActiveX.js" type="text/javascript"></script>
    <script type="text/javascript">
    AC_FL_RunContent( \'codebase\',\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\',\'width\',\'100\',\'height\',\'100\',\'src\',\'click_test\',\'quality\',\'high\',\'FlashVars\',\'file='.$numb.'\',\'wmode\',\'opaque\',\'pluginspage\',\'http://www.macromedia.com/go/getflashplayer\',\'movie\',\'click_test\' ); //end AC code
    </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100" height="100">
      <param name="movie" value="click_test.swf" />
      <param name="quality" value="high" />
      <param name="FlashVars" value="file='.$numb.'" />
      <param name="wmode" value="opaque" />
      <embed src="click_test.swf" quality="high" FlashVars="'.$numb.'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="opaque" width="100" height="100"></embed>
    </object></noscript>';
    ?>
    Also, while you are still within the php tags, you do not need to call variables like so: <?php echo $numb;?>, but instead call them directly (as I fixed in the code above).
    Hope this helps.
    Last edited by thetestingsite; 04-11-2007 at 01:26 AM.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    This is a way to avoid such situations, when there's a long string of text:
    <?php
    $var = <<<OUT
    anything you want here... whatever
    line breaks, etc.
    just fine.
    OUT;
    ?>

    Just be sure to start and end just like that, with the same 'word' (or whatever), and the <<</; setup.
    It works great.

    Or, you can just end the PHP, like this--
    if (1==1) { ?> hello <?php }

    That would only write that html if the IF evaluates to true.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Aug 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks the code worked great however the script didnt

    I get this wmode bugg in mozilla, when you use the scroll the object get inactive.

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It's a bit vague at this point, not being able to see the page.
    Since PHP code needs to first be parsed, it'll be easier to work with the output html.
    A link to your page would be very helpful.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Aug 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The code worked, all the data was correct but the thing is wmode will make the flash inactive when using the scroller if your browsing with mozilla. Even adobes own homepage example of wmode is bugged which is quite ironic
    I thought there was a workaround but guess theres not I think I will go with the swfobject.js method now as its less code.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •