Graxeon Posted June 3, 2008 Share Posted June 3, 2008 Ok, so I have this: <html><body> <h4>Title Here</h4> <form action="process2.php" method="post"> <select name="playlists"> <option>Playlist1</option> <option>Playlist2</option> <option>Playlist3</option> </select> Episode: <input name="episode" type="text" /> <input type="submit" /> </form> </body></html> And that leads to this: $playlists = "Playlist1"; if ( $episode == "1" ) { echo "E1!<br />"; } if ( $episode == "2" ) { echo "E2!<br />"; } if ( $episode == "3" ) { echo "E3!<br />"; } echo "Welcome to my homepage!"; </body> </html> When I select Playlist1 and put 1 for the Episode, I get this on process2.php: $playlists = "Playlist1"; if ( $episode == "1" ) { echo "E1! "; } if ( $episode == "2" ) { echo "E2! "; } if ( $episode == "3" ) { echo "E3! "; } echo "Welcome to my homepage!"; I acually just want it to say E1! For that, I need a way of adding multiple "if"s After that is done, I'm going to change the E#!s into this script for each episode: <script type="text/javascript" src="swfobject.js"></script> <div id="player">Playlist# - Episode #</div> <script type="text/javascript">var so = new SWFObject('mediaplayer.swf','mpl','480','272','8'); so.addParam('allowscriptaccess','always'); so.addParam('allowfullscreen','true'); so.addVariable('height','272'); so.addVariable('width','480'); so.addVariable('file','playlist#episode#.flv'); so.addVariable('logo','watermark.png'); so.addVariable('searchbar','false'); so.addVariable('showstop','true'); so.write('player'); </script> So that means that I need a way of running that script in the if's echo attribute. I tried adding that script instead of the E# but it came out really messed up. Can anyone help me fix this problem? I did read through the PHP manual (the things that I was looking for) but with not much of an outcome. I acually despise that manual because they don't give examples...they just say what happens. Please don't point me to that manual, I wasted 2 hours on it for no reason. Thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/108558-echo-script-and-ifs/ Share on other sites More sharing options...
Gamic Posted June 3, 2008 Share Posted June 3, 2008 PHP code is wrapped in <?php ?> tags. From your example it appears that you did not do this. Quote Link to comment https://forums.phpfreaks.com/topic/108558-echo-script-and-ifs/#findComment-556651 Share on other sites More sharing options...
revraz Posted June 3, 2008 Share Posted June 3, 2008 You already started a thread on this. Why not just bump that one instead creating a whole new one and starting over? I'm not going to waste my time trying to help if that info is just going to be wasted. Quote Link to comment https://forums.phpfreaks.com/topic/108558-echo-script-and-ifs/#findComment-556654 Share on other sites More sharing options...
Graxeon Posted June 3, 2008 Author Share Posted June 3, 2008 You already started a thread on this. Why not just bump that one instead creating a whole new one and starting over? I'm not going to waste my time trying to help if that info is just going to be wasted. I know, Im sorry. That topic wasn't heading in the correct direction I wanted it to go. I did get an answer for it but I wasn't going to go through the process of creating all of those things. Having a DB, Mysql, etc... I now just need a simple way of using the echo and ifs. Quote Link to comment https://forums.phpfreaks.com/topic/108558-echo-script-and-ifs/#findComment-556676 Share on other sites More sharing options...
Graxeon Posted June 3, 2008 Author Share Posted June 3, 2008 PHP code is wrapped in <?php ?> tags. From your example it appears that you did not do this. Sorry for the double post, but I've made a step towards fixing this. I'm amazed I forgot to put those tags...wow... But yeah, with the tags the E1! showed up and it works. I tried putting the flash player script in it but it came out with this: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\Program Files\apachefriends\xampp\htdocs\process2.php on line 11 Any ideas on how to run that script in place of the E#!s? Here's the process2.php file: <html> <head> <title></title> </head> <body> <?php $playlists = "Playlist1"; if ( $episode == "1" ) { echo "<script type="text/javascript" src="swfobject.js"></script> <div id="player">Playlist# - Episode #</div> <script type="text/javascript">var so = new SWFObject('mediaplayer.swf','mpl','480','272','8'); so.addParam('allowscriptaccess','always'); so.addParam('allowfullscreen','true'); so.addVariable('height','272'); so.addVariable('width','480'); so.addVariable('file','playlist#episode#.flv'); so.addVariable('logo','watermark.png'); so.addVariable('searchbar','false'); so.addVariable('showstop','true'); so.write('player'); </script><br />"; } if ( $episode == "2" ) { echo "E2!<br />"; } if ( $episode == "3" ) { echo "E3!<br />"; } echo "Welcome to my homepage!"; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/108558-echo-script-and-ifs/#findComment-556915 Share on other sites More sharing options...
Gamic Posted June 5, 2008 Share Posted June 5, 2008 You have to either escape your quotes inside of your strings or you have to use single quotes for your html attributes. <?php echo("<script type='text/javascript'></script>"); ?> so this: <?php echo "<script type="text/javascript" src="swfobject.js"></script> <div id="player">Playlist# - Episode #</div> <script type="text/javascript">var so = new SWFObject('mediaplayer.swf','mpl','480','272','8'); so.addParam('allowscriptaccess','always'); so.addParam('allowfullscreen','true'); so.addVariable('height','272'); so.addVariable('width','480'); so.addVariable('file','playlist#episode#.flv'); so.addVariable('logo','watermark.png'); so.addVariable('searchbar','false'); so.addVariable('showstop','true'); so.write('player'); </script><br />"; ?> would become this <?php echo "<script type='text/javascript' src='swfobject.js'></script> <div id='player'>Playlist# - Episode #</div> <script type='text/javascript'>var so = new SWFObject('mediaplayer.swf','mpl','480','272','8'); so.addParam('allowscriptaccess','always'); so.addParam('allowfullscreen','true'); so.addVariable('height','272'); so.addVariable('width','480'); so.addVariable('file','playlist#episode#.flv'); so.addVariable('logo','watermark.png'); so.addVariable('searchbar','false'); so.addVariable('showstop','true'); so.write('player'); </script><br />"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/108558-echo-script-and-ifs/#findComment-558433 Share on other sites More sharing options...
Graxeon Posted June 7, 2008 Author Share Posted June 7, 2008 That made the player show up if I DONT put the <?php ?> wrappers. I got this as a result: $playlists = "Playlist1"; if ( $episode == "1" ) { echo " THE FLASH PLAYER IS SHOWN HERE "; } if ( $episode == "2" ) { echo "E2! "; } if ( $episode == "3" ) { echo "E3! "; } echo "Welcome to my homepage!"; However, the player doesn't play anything if the play button is pressed (it just has the little "loading" thing spinning around). If I DO put the wrappers, then nothing comes up the the process page. I have this: <html> <body> <?php $playlists = "Playlists1"; if ( $episode == "1" ) { echo "<script type='text/javascript' src='swfobject.js'></script> <div id='player'>Playlist# - Episode #</div> <script type='text/javascript'>var so = new SWFObject('mediaplayer.swf','mpl','480','272','8'); so.addParam('allowscriptaccess','always'); so.addParam('allowfullscreen','true'); so.addVariable('height','272'); so.addVariable('width','480'); so.addVariable('file','playlist#episode#.flv'); so.addVariable('logo','watermark.png'); so.addVariable('searchbar','false'); so.addVariable('showstop','true'); so.write('player'); </script><br />"; } if ( $episode == "2" ) { echo "E2!<br />"; } if ( $episode == "3" ) { echo "E3!<br />"; } echo "Welcome to my homepage!"; ?> </body> </html> Again, with the php wrappers, nothing shows up. Remove them and you get this: $playlists = "Playlist1"; if ( $episode == "1" ) { echo " THE FLASH PLAYER IS SHOWN HERE "; } if ( $episode == "2" ) { echo "E2! "; } if ( $episode == "3" ) { echo "E3! "; } echo "Welcome to my homepage!"; Help please? Quote Link to comment https://forums.phpfreaks.com/topic/108558-echo-script-and-ifs/#findComment-559557 Share on other sites More sharing options...
Graxeon Posted June 12, 2008 Author Share Posted June 12, 2008 Anyone know how to fix it? Quote Link to comment https://forums.phpfreaks.com/topic/108558-echo-script-and-ifs/#findComment-564114 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.