Results 1 to 8 of 8

Thread: Javascript/PHP Parse error, T_STRING

  1. #1
    Join Date
    Oct 2009
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Javascript/PHP Parse error, T_STRING

    Hello,

    I am in the process of updating a site to php to reduce time needed to update. Everything seems to be working until I add javascript for an embedded flash file then I get "Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'"

    Is it possible to re-write this code to be PHP friendly?

    Code:
    <?
    echo'
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>| Title |</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="author" content="FGA DF" />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <script type="text/javascript" src="js/swfobject.js"></script>
    <link href="css/dropdown.css" media="all" rel="stylesheet" type="text/css" />
    <link href="css/default.advanced.css" media="all" rel="stylesheet" type="text/css" />
    </head>
    <script type= "text/javascript">
    			Var params = {};
    		    params.bgcolor = "#FFFFFF";
    		    params.menu = "false";
    		    params.scale = 'noScale';
    		    params.wmode = "opaque";
    		    params.allowScriptAccess = "always";
    		    
    		    var attributes = {};
    		    attributes.id = 'Component';
    		    attributes.name = 'Component'
    		    
    			var cacheBuster = Date.parse(new Date());		    
    		    
    		    var stageW = 550;
    			var stageH = 374; 
    			
    		    var flashvars = {};
    		    
    		    flashvars.componentWidth = 560;
    			flashvars.componentHeight = 374;
    			
    			flashvars.pathToFiles = "banner/";
    			
    			flashvars.xmlPath = "xml/banner.xml";
    		           
                swfobject.embedSWF('preview.swf', 'Component', stageW, stageH, '9.0.45', 'js/expressinstall.swf', flashvars, params, attributes);
               
            </script>
    <body>
    <div class="centered">
          <table width="73%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" summary="summary" valign="top">
      <tr bgcolor="#000000">
        <th colspan="3" scope="col"> <div align="right">
            <a href="./" target="_parent"><img src="images/concept_banner.jpg" alt="" width="950" height="111" /></a>
            <div align="center">
              <ul class="dropdown dropdown-horizontal">
                <li id="Home"><a href="./" target="_parent" class="dir">Home</a></li>
                <li id="ACS"><a href="../." class="dir"> Community Services</a>
                    <ul>
                      <li><a href="../.">Information and Referral</a></li>
                      <li><a href="../.">Financial Readiness</a></li>
                      <li><a href="../."> Emergency Relief</a></li>
                      <li><a href="../.">Employment Assistance</a></li>
                      <li><a href="../.">Exceptional Family Member</a></li>
                      <li><a href="../.">Mobilization and Deployment Readiness</a></li>
                      <li><a href="../.">Relocation Readiness</a></li>
                      <li><a href="../.">Family Advocacy</a></li>
                      <li><a href="../.">Sexual Assault Response</a></li>
                      <li><a href="../."> Family Team Building</a></li>
                      <li><a href="../."> Family Action Plan</a></li>
                      <li><a href="../."> Volunteer Corps </a></li>
                    </ul>
                </li>
                <li id="CYS"><a href="../." class="dir">Child Youth &amp; School Services</a>
                    <ul>
                      <li><a href="../.">Central Registration</a></li>
                      <li><a href="../.">Child Development Center</a></li>
                      <li><a href="../.">Family Child Care</a></li>
                      <li><a href="../.">School Age Services</a></li>
                      <li><a href="../.">Youth Services</a></li>
                      <li><a href="../.">Youth Sports and Fitness</a></li>
                      <li><a href="../.">School Liaison</a></li>
                      <li><a href="../.">Skies Unlimited</a></li>
                    </ul>
                </li>
                <li id="Recreation"><a href="../." class="dir">Recreation</a>
                    <ul>
                      <li><a href="../.">Physical Fitness Center</a></li>
                      <li><a href="../.">Auto Skills Shop</a></li>
                      <li><a href="../.">Outdoor Recreation</a></li>
                      <li><a href="../.">Wood Craft Shop</a></li>
                      <li><a href="../.">Indoor Playground</a></li>
                      <li><a href="../.">BOSS Warrior Zone</a></li>
                      <li><a href="../.">Sideline Sports Bar</a></li>
                    </ul>
                </li>
                <li id="Lodging"><a href="../." class="dir">Lodging</a> </li>
                <li id=""><a href="../." class="dir"> Information</a>
                    <ul>
                      <li><a href="../.">Events Calendar</a></li>
                      <li><a href="../.">Administration</a></li>
                      <li><a href="../.">Locations Map</a></li>
                      <li><a href="../.">Phone Numbers</a></li>
                      <li><a href="../.">NAF Employment</a></li>
                    </ul>
                </li>
              </ul>
            </div></th>
      </tr>
    </table>
    </body>
    </html>
    ';
    ?>
    Last edited by djr33; 10-22-2009 at 05:01 AM.

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

    Default

    You need to include the PHP code as well in order for us to successfully help you.
    "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. The Following User Says Thank You to thetestingsite For This Useful Post:

    tcoble (10-22-2009)

  4. #3
    Join Date
    Oct 2009
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Here is the full code:

    Code:
    <?
    echo'
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>| Title |</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="author" content="FGA DF" />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <script type="text/javascript" src="js/swfobject.js"></script>
    <link href="css/dropdown.css" media="all" rel="stylesheet" type="text/css" />
    <link href="css/default.advanced.css" media="all" rel="stylesheet" type="text/css" />
    </head>
    <script type= "text/javascript">
    			Var params = {};
    		    params.bgcolor = "#FFFFFF";
    		    params.menu = "false";
    		    params.scale = 'noScale';
    		    params.wmode = "opaque";
    		    params.allowScriptAccess = "always";
    		    
    		    var attributes = {};
    		    attributes.id = 'Component';
    		    attributes.name = 'Component'
    		    
    			var cacheBuster = Date.parse(new Date());		    
    		    
    		    var stageW = 550;
    			var stageH = 374; 
    			
    		    var flashvars = {};
    		    
    		    flashvars.componentWidth = 560;
    			flashvars.componentHeight = 374;
    			
    			flashvars.pathToFiles = "banner/";
    			
    			flashvars.xmlPath = "xml/banner.xml";
    		           
                swfobject.embedSWF('preview.swf', 'Component', stageW, stageH, '9.0.45', 'js/expressinstall.swf', flashvars, params, attributes);
               
            </script>
    <body>
    <div class="centered">
          <table width="73%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" summary="summary" valign="top">
      <tr bgcolor="#000000">
        <th colspan="3" scope="col"> <div align="right">
            <a href="./" target="_parent"><img src="images/concept_banner.jpg" alt="" width="950" height="111" /></a>
            <div align="center">
              <ul class="dropdown dropdown-horizontal">
                <li id="Home"><a href="./" target="_parent" class="dir">Home</a></li>
                <li id="ACS"><a href="../." class="dir"> Community Services</a>
                    <ul>
                      <li><a href="../.">Information and Referral</a></li>
                      <li><a href="../.">Financial Readiness</a></li>
                      <li><a href="../."> Emergency Relief</a></li>
                      <li><a href="../.">Employment Assistance</a></li>
                      <li><a href="../.">Exceptional Family Member</a></li>
                      <li><a href="../.">Mobilization and Deployment Readiness</a></li>
                      <li><a href="../.">Relocation Readiness</a></li>
                      <li><a href="../.">Family Advocacy</a></li>
                      <li><a href="../.">Sexual Assault Response</a></li>
                      <li><a href="../."> Family Team Building</a></li>
                      <li><a href="../."> Family Action Plan</a></li>
                      <li><a href="../."> Volunteer Corps </a></li>
                    </ul>
                </li>
                <li id="CYS"><a href="../." class="dir">Child Youth &amp; School Services</a>
                    <ul>
                      <li><a href="../.">Central Registration</a></li>
                      <li><a href="../.">Child Development Center</a></li>
                      <li><a href="../.">Family Child Care</a></li>
                      <li><a href="../.">School Age Services</a></li>
                      <li><a href="../.">Youth Services</a></li>
                      <li><a href="../.">Youth Sports and Fitness</a></li>
                      <li><a href="../.">School Liaison</a></li>
                      <li><a href="../.">Skies Unlimited</a></li>
                    </ul>
                </li>
                <li id="Recreation"><a href="../." class="dir">Recreation</a>
                    <ul>
                      <li><a href="../.">Physical Fitness Center</a></li>
                      <li><a href="../.">Auto Skills Shop</a></li>
                      <li><a href="../.">Outdoor Recreation</a></li>
                      <li><a href="../.">Wood Craft Shop</a></li>
                      <li><a href="../.">Indoor Playground</a></li>
                      <li><a href="../.">BOSS Warrior Zone</a></li>
                      <li><a href="../.">Sideline Sports Bar</a></li>
                    </ul>
                </li>
                <li id="Lodging"><a href="../." class="dir">Lodging</a> </li>
                <li id=""><a href="../." class="dir"> Information</a>
                    <ul>
                      <li><a href="../.">Events Calendar</a></li>
                      <li><a href="../.">Administration</a></li>
                      <li><a href="../.">Locations Map</a></li>
                      <li><a href="../.">Phone Numbers</a></li>
                      <li><a href="../.">NAF Employment</a></li>
                    </ul>
                </li>
              </ul>
            </div></th>
      </tr>
    </table>
    </body>
    </html>
    ';
    ?>
    Last edited by djr33; 10-22-2009 at 05:01 AM.

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

    Default

    Being that you are using single quotes for the echo, you have to use double quotes or escape the sinle quotes in your javascript code.

    Hope this helps.
    "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

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

    Default

    PHP Code:
    <?php
    $var 
    'test'test'; //error '
    $var 'test\'test'//no error
    ?>
    You must escape similar quotes:
    If you are using ', you need to escape with \' for 's.
    If you are using ", you need to escape with \" for "s.

    There is an alternative way to echo large chunks of data, but that requires using a special format and it can be annoying to use.
    More info here: http://www.php.net/manual/en/function.echo.php
    (Look in the example block for <<<END .... END;.)


    Also, if you have long chunks of text, you can do that by exiting PHP for direct text, but within an if:
    PHP Code:
    <?php
    if ($var == 1) { ?>
    test test test test
    test test test test
    test .....
    <?php }
    //the text above is only output when the if returns true.
    ?>

    So there are some ideas to work with. You could also try a more complex strategy, storing your layout and content somewhere else (database, text files) and including those into your php code to generate the site. That's a better idea if you are making a complex, large site, though it takes a lot of work to setup.
    Last edited by djr33; 10-22-2009 at 05:00 AM.
    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

  7. The Following User Says Thank You to djr33 For This Useful Post:

    tcoble (10-22-2009)

  8. #6
    Join Date
    Oct 2009
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much. I am trying it now.

    Thanks for the edit djr33.

  9. #7
    Join Date
    Oct 2008
    Posts
    60
    Thanks
    2
    Thanked 7 Times in 7 Posts

    Default

    Hello,
    when it says "syntax error, unexpected T_STRING, expecting ',' or ';'"
    it means that your missing a comma or semicolon. If you look close:
    HTML Code:
    attributes.id = 'Component'; <-- Semicolon
    attributes.name = 'Component' <-- No Semicolon. ADD ONE..
    Hope this helped

  10. #8
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    tcoble,

    Unless you have changed something in your code since your first post, you do not, and should not, need to use php to output what you have there.

    What are you trying to achieve by using php to echo all that markup?

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
  •