Imbed flash in PHP Switch Statement

Discussion in 'PHP' started by smorse1, Apr 25, 2008.

  1. #1
    Hi,
    Novice to php, so here goes:
    need to vary a handful of flash banners by a passed in variable, and I am using a Switch statement - here's the code
    switch ($j)
    {
    case 10:
    echo "value of $ j = 0 <br> ";
    break;

    case 11:
    echo "value of $ j = 1 <br> ";
    break;

    case 12:
    echo "value of $ j = 2 <br> ";
    break;

    case 13:
    echo "value of $ j = 3 <br> ";
    break;

    case 8:
    print '<script type="text/javascript">
    AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','480','height','80','src','../pages/shopbanner','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','../pages/shopbanner' ); //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=9,0,28,0" width="480" height="80">
    <param name="movie" value="../pages/shopbanner.swf" />
    <param name="quality" value="high" />
    <embed src="../pages/shopbanner.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="480" height="80"></embed>
    </object></noscript>';
    break;

    default:
    echo "value of $ j = Default value <br> ";
    break;
    }

    any idea why the page bombs when it hits the script condition? It is probably something stupid, and maybe there is a better way to conditionally include the code?
    Thanks in advance!
     
    smorse1, Apr 25, 2008 IP
  2. dgxshiny

    dgxshiny Greenhorn

    Messages:
    65
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    23
    #2
    Try escaping the single quotes within the print with a '. You have nested single quotes which is causing your error. Within the print put a \ before each '.

    ie: AC_FL_RunContent( \'codebase\' ......... etc
     
    dgxshiny, Apr 25, 2008 IP
  3. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Change the "case 8" section to:
    case 8:
    print <<<EOD
    <script type="text/javascript">
    AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','480','height','80','src','../pages/shopbanner','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','../pages/shopbanner' ); //end AC code
    </script><noscript><object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="480" height="80">
    <param name="movie" value="../pages/shopbanner.swf" />
    <param name="quality" value="high" />
    <embed src="../pages/shopbanner.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="480" height="80"></embed>
    </object></noscript>
    EOD;
    break;
    Code (markup):
     
    krt, Apr 25, 2008 IP
  4. smorse1

    smorse1 Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks guys - the escaping the single quotes got the job done!
     
    smorse1, Apr 26, 2008 IP