zero742 Posted October 14, 2009 Share Posted October 14, 2009 This is my first major project in PHP and I'm having some trouble embedding a flash object in an Else statement. I've googled it several times, and looked at several sites and they all seem to suggest displaying it with show or echo or print. I've tried them all and show returns: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/content/m/b/a/mbaveterans/html/Network/resumebook.php on line 107 echo returns: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/content/m/b/a/mbaveterans/html/Network/resumebook.php on line 107 print returns: Parse error: syntax error, unexpected T_STRING in /home/content/m/b/a/mbaveterans/html/Network/resumebook.php on line 107 The If..Else statement is below <?php if ($pass != $info['password']) { header("Location: login.php"); } else { print "<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="doc_804151193636402" name="doc_804151193636402" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle" height="500" width="100%" >"; print "<param name="movie" value="./flash/book.swf">"; print "<param name="quality" value="high">"; print "<param name="play" value="true">"; print "<param name="loop" value="true">"; print "<param name="scale" value="showall">"; print "<param name="wmode" value="opaque">"; print "<param name="devicefont" value="false">"; print "<param name="bgcolor" value="#ffffff">"; print "<param name="menu" value="true">"; print "<param name="allowFullScreen" value="true">"; print "<param name="allowScriptAccess" value="always">"; print "<param name="salign" value="">"; print "<embed src="./flash/book.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" scale="showall" wmode="opaque" devicefont="false" bgcolor="#ffffff" name="doc_804151193636402_object" menu="true" allowfullscreen="true" allowscriptaccess="always" salign="" type="application/x-shockwave-flash" align="middle" height="650" width="100%">"; print "</embed>"; print "</object>"; echo "<a href=logout.php>Logout</a>"; } } } ?> Any ideas would be much appreciated. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/177693-solved-embedding-flash-object-in-else-statement/ Share on other sites More sharing options...
simshaun Posted October 14, 2009 Share Posted October 14, 2009 You need to escape your double quotes in the print statements, or use single quotes to wrap the strings instead of double quotes. Quote Link to comment https://forums.phpfreaks.com/topic/177693-solved-embedding-flash-object-in-else-statement/#findComment-936917 Share on other sites More sharing options...
ialsoagree Posted October 14, 2009 Share Posted October 14, 2009 Also, if you have no PHP written in your strings, you shouldn't be using double quotes. Double quotes tell PHP to parse the string for PHP syntax (IE. look for and interpret variables, functions, etc.). This uses processing cycles. If you know before hand that there's no PHP in the strings, why waste processing cycles processing PHP where there is none? I've personally abandoned the use of double quotes simply because it makes PHP programming as a whole easier for me. I always know that variables and functions have to be concatenated to the string and that single quotes have to be escaped. I also never waste processing cycles parsing a string for PHP that doesn't have any PHP in it. Quote Link to comment https://forums.phpfreaks.com/topic/177693-solved-embedding-flash-object-in-else-statement/#findComment-936924 Share on other sites More sharing options...
zero742 Posted October 14, 2009 Author Share Posted October 14, 2009 I just went through and replaced all the " with ' and I am getting the same errors. <?php if ($pass != $info['password']) { header('Location: login.php'); } else { print '<object codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' id='doc_804151193636402' name='doc_804151193636402' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' align='middle' height='500' width='100%' >'; print '<param name='movie' value='./flash/book.swf'>'; print '<param name='quality' value='high'>'; print '<param name='play' value='true'>'; print '<param name='loop' value='true'>'; print '<param name='scale' value='showall'>'; print '<param name='wmode' value='opaque'>'; print '<param name='devicefont' value='false'>'; print '<param name='bgcolor' value='#ffffff'>'; print '<param name='menu' value='true'>'; print '<param name='allowFullScreen' value='true'>'; print '<param name='allowScriptAccess' value='always'>'; print '<param name='salign' value=''>'; print '<embed src='./flash/book.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' play='true' loop='true' scale='showall' wmode='opaque' devicefont='false' bgcolor='#ffffff' name='doc_804151193636402_object' menu='true' allowfullscreen='true' allowscriptaccess='always' salign='' type='application/x-shockwave-flash' align='middle' height='650' width='100%'>'; print '</embed>'; print '</object>'; echo '<a href=logout.php>Logout</a>'; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/177693-solved-embedding-flash-object-in-else-statement/#findComment-936932 Share on other sites More sharing options...
ialsoagree Posted October 14, 2009 Share Posted October 14, 2009 You're getting the same error because you replace ALL the double quotes with single quotes. To give you a clue as to what's going on: PHP recognizes all of this normally: print '<object codebase=' PHP throws an error when it sees this: http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0 It's not a string (you've closed your single quote, so PHP doesn't recognize it as being in the string), you didn't end your line with a semicolon, and you didn't concatenate to your string. Thus, it's a syntax error, PHP throws an error. This would be another string, but once again since it's not concatenated, it would result in a PHP parse error: 'doc_804151193636402' Now your outside the string again: name= Now you're inside the string again: 'doc_804151193636402' etc. Instead, you need to escape your single quotes (or change them back to double quotes) so PHP knows the difference: <?php print '<object codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\' id=\'doc_804151193636402\' name=\'doc_804151193636402\' classid=\'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\' align=\'middle\' height=\'500\' width=\'100%\' >'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/177693-solved-embedding-flash-object-in-else-statement/#findComment-936937 Share on other sites More sharing options...
mrMarcus Posted October 14, 2009 Share Posted October 14, 2009 he doesn't need to escape all the quotes if done correctly: print '<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="doc_804151193636402" name="doc_804151193636402" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle" height="500" width="100%" >'; is fine .. and so on... Quote Link to comment https://forums.phpfreaks.com/topic/177693-solved-embedding-flash-object-in-else-statement/#findComment-936940 Share on other sites More sharing options...
zero742 Posted October 14, 2009 Author Share Posted October 14, 2009 I've tried it both ways (replacing ' with \' and ' with ", where appropriate) and get the same result. <?php show '<object codebase=\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\' id=\'doc_804151193636402\' name=\'doc_804151193636402\' classid=\'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\' align=\'middle\' height=\'500\' width=\'100%\' >'; show '<param name=\'movie\' value=\'http://d1.scribdassets.com/ScribdViewer.swf?document_id=20832349&access_key=key-1hrozrvk2nlygfx36t1j&page=1&version=1&viewMode=\'>'; ?> <?php show '<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="doc_804151193636402" name="doc_804151193636402" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle" height="500" width="100%" >'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/177693-solved-embedding-flash-object-in-else-statement/#findComment-936951 Share on other sites More sharing options...
ialsoagree Posted October 14, 2009 Share Posted October 14, 2009 he doesn't need to escape all the quotes if done correctly: print '<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="doc_804151193636402" name="doc_804151193636402" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle" height="500" width="100%" >'; is fine .. and so on... I guess it's good that I said the exact same thing then? "Instead, you need to ... change them back to double quotes ... so PHP knows the difference:" EDIT: Show should be print or echo? Quote Link to comment https://forums.phpfreaks.com/topic/177693-solved-embedding-flash-object-in-else-statement/#findComment-936953 Share on other sites More sharing options...
dreamwest Posted October 14, 2009 Share Posted October 14, 2009 <?php if ($pass != $info['password']) { header('Location: /login.php'); } else { print "<object codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' id='doc_804151193636402' name='doc_804151193636402' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' align='middle' height='500' width='100%' >"; print "<param name='movie' value='./flash/book.swf'>"; print "<param name='quality' value='high'>"; print "<param name='play' value='true'>"; print "<param name='loop' value='true'>"; print "<param name='scale' value='showall'>"; print "<param name='wmode' value='opaque'>"; print "<param name='devicefont' value='false'>"; print "<param name='bgcolor' value='#ffffff'>"; print "<param name='menu' value='true'>"; print "<param name='allowFullScreen' value='true'>"; print "<param name='allowScriptAccess' value='always'>"; print "<param name='salign' value=''>"; print "<embed src='./flash/book.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' play='true' loop='true' scale='showall' wmode='opaque' devicefont='false' bgcolor='#ffffff' name='doc_804151193636402_object' menu='true' allowfullscreen='true' allowscriptaccess='always' salign='' type='application/x-shockwave-flash' align='middle' height='650' width='100%'>"; print '</embed>'; print '</object>'; echo '<a href=logout.php>Logout</a>'; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/177693-solved-embedding-flash-object-in-else-statement/#findComment-936962 Share on other sites More sharing options...
zero742 Posted October 14, 2009 Author Share Posted October 14, 2009 This made progress of sorts. Now instead of an error, it produces a blank page. <?php if ($pass != $info['password']) { header('Location: /login.php'); } else { print "<object codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' id='doc_804151193636402' name='doc_804151193636402' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' align='middle' height='500' width='100%' >"; print "<param name='movie' value='./flash/book.swf'>"; print "<param name='quality' value='high'>"; print "<param name='play' value='true'>"; print "<param name='loop' value='true'>"; print "<param name='scale' value='showall'>"; print "<param name='wmode' value='opaque'>"; print "<param name='devicefont' value='false'>"; print "<param name='bgcolor' value='#ffffff'>"; print "<param name='menu' value='true'>"; print "<param name='allowFullScreen' value='true'>"; print "<param name='allowScriptAccess' value='always'>"; print "<param name='salign' value=''>"; print "<embed src='./flash/book.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' play='true' loop='true' scale='showall' wmode='opaque' devicefont='false' bgcolor='#ffffff' name='doc_804151193636402_object' menu='true' allowfullscreen='true' allowscriptaccess='always' salign='' type='application/x-shockwave-flash' align='middle' height='650' width='100%'>"; print '</embed>'; print '</object>'; echo '<a href=logout.php>Logout</a>'; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/177693-solved-embedding-flash-object-in-else-statement/#findComment-936969 Share on other sites More sharing options...
ialsoagree Posted October 14, 2009 Share Posted October 14, 2009 This appears to be a code snippet rather than the whole page (I'm basing this off the fact that you're ending your code with multiple brackets). Is it possible that you have an if condition that could be met but wouldn't produce output, or is it possible that you have an if condition that doesn't have an else? Checking the HTML source might provide a clue as to the problem. Quote Link to comment https://forums.phpfreaks.com/topic/177693-solved-embedding-flash-object-in-else-statement/#findComment-936974 Share on other sites More sharing options...
mrMarcus Posted October 14, 2009 Share Posted October 14, 2009 reverse your single and double quotes for a more efficient script and better practice. and, ialsoagree with ialsoagree .. check your code as encouraged. Quote Link to comment https://forums.phpfreaks.com/topic/177693-solved-embedding-flash-object-in-else-statement/#findComment-936977 Share on other sites More sharing options...
zero742 Posted October 14, 2009 Author Share Posted October 14, 2009 I think you may be right. I started checking out my if's and found one dealing with a cookie that might be wrong. I'll check that out. Thanks. This appears to be a code snippet rather than the whole page (I'm basing this off the fact that you're ending your code with multiple brackets). Is it possible that you have an if condition that could be met but wouldn't produce output, or is it possible that you have an if condition that doesn't have an else? Checking the HTML source might provide a clue as to the problem. Quote Link to comment https://forums.phpfreaks.com/topic/177693-solved-embedding-flash-object-in-else-statement/#findComment-936978 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.