Jump to content

[SOLVED] Embedding flash object in Else statement


zero742

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>';
}
}
}
?>

Link to comment
Share on other sites

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%\' >';
?>

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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%" >';	
?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

<?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>';
}
}
}
?>

Link to comment
Share on other sites

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>';
}
}
}
?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.