Jump to content

Solved, But One More Question


ChidoriSoul

Recommended Posts

Hey, I am making a RPG, and my Index page to change for Logged in users, if giving me the error:Parse error: syntax error, unexpected '<' in /home/www/tparpg.awardspace.co.uk/index.php on line 24Yet, my code is kinda weird.

<?php// Connects to your Databasemysql_connect("fdb1.awardspace.com", "chidorisoul_sh", "******") or die(mysql_error());mysql_select_db("chidorisoul_sh") or die(mysql_error());//checks cookies to make sure they are logged inif(isset($_COOKIE['ID_my_site'])){$username = $_COOKIE['ID_my_site'];$pass = $_COOKIE['Key_my_site'];$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());while($info = mysql_fetch_array( $check )){//if the cookie has the wrong password, they are taken to the login pageif ($pass != $info['password']){ header("Location: index.php");}//otherwise they are shown the admin areaelse{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" xml:lang="en" lang="eng"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>The Pokemon Asteroid -- Online RPG by Shadow - Made by Shadow</title><style type="text/css"><!--body,td,th {    color: #FF0000;    font-family: Tahoma;    font-size: 9px;    font-weight: bold;}body {    background-color: #000000;}.thead {background: #302226;border: 1px solid #000000;border-bottom: 0px;text-align: center;vertical-align: middle;height: 15px;}.tnav {background: #302226;border: 1px solid #000000;border-bottom: 0px;text-align: center;height: 15px;}.tnav2 {background: #302226;border: 1px solid #000000;border-bottom: 1px solid black;text-align: center;height: 15px;}.news {background: #302226;border: 1px solid #000000;border-bottom: 1px solid #000000;text-align: center;height: 15px;}.banner {border-bottom: 0px;}.dis {border-top: 0px;}.con {border-top: 0px;border-bottom: 0px;}.party {background: #302226;border: 1px solid #000000;border-bottom: 0px;text-align: center;height: 25px;}a:link {    color: #990000;    text-decoration: none;}a:visited {    text-decoration: none;    color: #990000;}a:active {    text-decoration: none;    color: #FFFFFF;}.style1 {color: #FFFFFF}--></style></head><body><table align="center" width="200" height="247" border="0" cellpadding="0" cellspacing="0" bordercolor="#FF0000">  <tr>    <td align="left" valign="top"><table width="802" height="120" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000" class="banner">      <tr>        <th background="http://i286.photobucket.com/albums/ll84/ChidoriSoul/BetterAsteroidBanner.png?t=1243111409" scope="col"> </th>      </tr>    </table>      <table width="802" height="120" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000" class="con">        <tr><!--- Ads --><div style="text-align: center"><script type="text/javascript"><!--google_ad_client = "pub-4468899317544238";/* TPARPG */google_ad_slot = "0388012058";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div><!--- End of Ads --><!--- Left Nav -->                   <th width="122" align="center" valign="top" bgcolor="#302226" scope="row">                    <div class="thead style1" id="thead"> <font color='limegreen'>General Options</font> </div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/index.php"><font color='blue'>Index</font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/logout.php"><font color='blue'>Logout</font></a></div>                    <div class="thead style1" id="thead"> <font color='limegreen'>Miscellaneous</font> </div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/about.php"><font color='blue'>About TPA</font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/storyline.php"><font color='blue'>Storyline</font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/chatbox.php"><font color='blue'>Chatbox</font></a></div>          <div class="tnav"> <a href="http://www.punbb-hosting.com/forums/TPA_Forums/index.php"><font color='blue'>Forum</font></a></div>                    <div class="thead style1" id="thead"> <font color='limegreen'>Statistics</font> </div>          <div class="tnav"> <font color='blue'>Total Users: 0</font></div>                     </th><!--- End Of Left Nav --> <th width="520" align="center" valign="top" bgcolor="#302226" scope="row">          <div class="news" id="thead"> Index </div>                   <br /><br/><table width="100%" border="1"><tr><th>Avatar</th><th>News</th></tr><tr><td width="25%"><center><img src="http://i286.photobucket.com/albums/ll84/ChidoriSoul/ShadowDiagla.png" border="0" alt="Shadow Diagla"></center></td><td width="75%"><center>Register is finished. Now, Login, how exciting D<</center></td></tr></table><!--- Right Nav -->                   <th width="122" align="center" valign="top" bgcolor="#302226" scope="row">                    <div class="thead style1" id="thead"> <font color='limegreen'>General Options</font> </div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/index.php"><font color='blue'>Index</font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/register.php"><font color='blue'><del>Register</del></font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/login.php"><font color='blue'><del>Login</del></font></a></div>                     <div class="thead style1" id="thead"> <font color='limegreen'>Miscellaneous</font> </div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/about.php"><font color='blue'>About TPA</font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/storyline.php"><font color='blue'>Storyline</font></a></div>          <div class="tnav"> <a href="http://tparpg.awardspace.co.uk/chatbox.php"><font color='blue'>Chatbox</font></a></div>          <div class="tnav"> <a href="http://www.punbb-hosting.com/forums/TPA_Forums/index.php"><font color='blue'>Forum</font></a></div>                    <div class="thead style1" id="thead"> <font color='limegreen'>Statistics</font> </div>          <div class="tnav"> <font color='blue'>Total Users: 0</font></div>                     </th><!--- End Of Right Nav --><!--- Disclaimer --><table width="765" height="45" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF0000" "backgroundcolor="#302226" class="dis"><tr>    <td align="center" valign="top"><strong>Disclaimer</strong><br />   The Pokémon Asteroid RPG is © owned and coded by Shadow. All sprites are Copyrighted 2009 Pokémon © Nintendo, Game Freak, Creatures Ink all rights reserved.The Asteroid RPG! is not affiliated with the organizations listed above or any other organizations that have co-operated or are co-operating in the programming or making of Pokémon. The images are copyright of their respective owners. This RPG is best viewed with Firefox. </td>  </tr</table></a></div><br /><!--- End Of Disclaimer -->";echo "";echo "";}}}else//if the cookie does not exist, they are taken to the index screen{header("Location: index.php");}?>

Link to comment
Share on other sites

take a look at these lines:

 else { 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" xml:lang="en" lang="eng">

If you start a string with double quotes " the string will end when the next double quote occurs.Now, on this line the string starts and ends on the quotes marked on red. The rest of the line is considered a comment because of //echo "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">And then the <html tag is not recognized as php and throws an error

Link to comment
Share on other sites

The fix: take all your HTML out of the PHP instead of having it in an echo... or else use single quote marks within the echo double quotes... or else a backslash before all of your double quotes

Link to comment
Share on other sites

Ok, after a bit of editing, it now works, now, just one for question.The code that I am using, if they go to that page when not Logged in, they are redirected to the Login Page. How can I change this so that the Index page looks different when people are logged in and logged out.Where I think it should be changed:

echo "";echo "";}}}else//if the cookie does not exist, they are taken to the login screen{header("Location: login.php");}?>

Link to comment
Share on other sites

it depends on how much you want to be different... if you want it completely different you could redirect them to another page or just replace header() with whatever you want them to see... if there are just a few things you want different... just add little if..else statements within it instead of having the whole thing if else

Link to comment
Share on other sites

Thanks for you help, but there is one more problem.Whenever I log out, then try to go to the page, it appears all blank, there is no information

<?php// Connects to your Databasemysql_connect("fdb1.awardspace.com", "chidorisoul_sh", "******") or die(mysql_error());mysql_select_db("chidorisoul_sh") or die(mysql_error());//checks cookies to make sure they are logged inif(isset($_COOKIE['ID_my_site'])){$username = $_COOKIE['ID_my_site'];$pass = $_COOKIE['Key_my_site'];$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());while($info = mysql_fetch_array( $check )){//if the cookie has the wrong password, they are taken to the login pageif ($pass != $info['password']){ header("Location: index.php");}//otherwise they are shown the admin areaelse{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' xml:lang='en' lang='eng'><head><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' /><title>The Pokemon Asteroid -- Online RPG by Shadow - Made by Shadow</title><style type='text/css'><!--body,td,th {    color: #FF0000;    font-family: Tahoma;    font-size: 9px;    font-weight: bold;}body {    background-color: #000000;}.thead {background: #302226;border: 1px solid #000000;border-bottom: 0px;text-align: center;vertical-align: middle;height: 15px;}.tnav {background: #302226;border: 1px solid #000000;border-bottom: 0px;text-align: center;height: 15px;}.tnav2 {background: #302226;border: 1px solid #000000;border-bottom: 1px solid black;text-align: center;height: 15px;}.news {background: #302226;border: 1px solid #000000;border-bottom: 1px solid #000000;text-align: center;height: 15px;}.banner {border-bottom: 0px;}.dis {border-top: 0px;}.con {border-top: 0px;border-bottom: 0px;}.party {background: #302226;border: 1px solid #000000;border-bottom: 0px;text-align: center;height: 25px;}a:link {    color: #990000;    text-decoration: none;}a:visited {    text-decoration: none;    color: #990000;}a:active {    text-decoration: none;    color: #FFFFFF;}.style1 {color: #FFFFFF}--></style></head><body><table align='center' width='200' height='247' border='0' cellpadding='0' cellspacing='0' bordercolor='#FF0000'>  <tr>    <td align='left' valign='top'><table width='802' height='120' border='1' cellpadding='0' cellspacing='0' bordercolor='#FF0000' class='banner'>      <tr>        <th background='http://i286.photobucket.com/albums/ll84/ChidoriSoul/BetterAsteroidBanner.png?t=1243111409' scope='col'> </th>      </tr>    </table>      <table width='802' height='120' border='1' cellpadding='0' cellspacing='0' bordercolor='#FF0000' class='con'>        <tr><!--- Ads --><div style='text-align: center'><script type='text/javascript'><!--google_ad_client = 'pub-4468899317544238';/* TPARPG */google_ad_slot = '0388012058';google_ad_width = 728;google_ad_height = 90;//--></script><script type='text/javascript'src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script></div><!--- End of Ads --><!--- Left Nav -->                   <th width='122' align='center' valign='top' bgcolor='#302226' scope='row'>                    <div class='thead style1' id='thead'> <font color='limegreen'>General Options</font> </div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/index.php'><font color='blue'>Index</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/logout.php'><font color='blue'>Logout</font></a></div>                    <div class='thead style1' id='thead'> <font color='limegreen'>Miscellaneous</font> </div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/about.php'><font color='blue'>About TPA</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/storyline.php'><font color='blue'>Storyline</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/chatbox.php'><font color='blue'>Chatbox</font></a></div>          <div class='tnav'> <a href='http://www.punbb-hosting.com/forums/TPA_Forums/index.php'><font color='blue'>Forum</font></a></div>                    <div class='thead style1' id='thead'> <font color='limegreen'>Statistics</font> </div>          <div class='tnav'> <font color='blue'>Total Users: 0</font></div>                     </th><!--- End Of Left Nav --> <th width='520 align='center' valign='top' bgcolor='#302226' scope='row'>          <div class='news' id='thead'> Index </div>                   <br /><br/><table width='100%' border='1'><tr><th>Avatar</th><th>News</th></tr><tr><td width='25%'><center><img src='http://i286.photobucket.com/albums/ll84/ChidoriSoul/ShadowDiagla.png' alt='Shadow Diagla' /></center></td><td width='75%'><center>Register and Login are both finished, just, I need to update this page, so it makes more sense for people that are logged out</center></td></tr></table><!--- Right Nav -->                   <th width='122' align='center' valign='top' bgcolor='#302226' scope='row'>                    <div class='thead style1' id='thead'> <font color='limegreen'>General Options</font> </div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/index.php'><font color='blue'>Index</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/logout.php'><font color='blue'>Logout</font></a></div>                     <div class='thead style1' id='thead'> <font color='limegreen'>Miscellaneous</font> </div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/about.php'><font color='blue'>About TPA</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/storyline.php'><font color='blue'>Storyline</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/chatbox.php'><font color='blue'>Chatbox</font></a></div>          <div class='tnav'> <a href='http://www.punbb-hosting.com/forums/TPA_Forums/index.php'><font color='blue'>Forum</font></a></div>                    <div class='thead style1' id='thead'> <font color='limegreen'>Statistics</font> </div>          <div class='tnav'> <font color='blue'>Total Users: 0</font></div>                     </th><!--- End Of Right Nav --><!--- Disclaimer --><table width='765' height='45' border='1' align='center' cellpadding='0' cellspacing='0' bordercolor='#FF0000' backgroundcolor='#302226' class='dis'><tr>    <td align='center' valign='top'><strong>Disclaimer</strong><br />   The Pokémon Asteroid RPG is © owned and coded by Shadow. All sprites are Copyrighted 2009 Pokémon © Nintendo, Game Freak, Creatures Ink all rights reserved.The Asteroid RPG is not affiliated with the organizations listed above or any other organizations that have co-operated or are co-operating in the programming or making of Pokémon. The images are copyright of their respective owners. This RPG is best viewed with Firefox. </td>  </tr></table></a></div><br /><!--- End Of Disclaimer -->";echo "";echo "";}}}else//if the cookie does not exist, they are taken to the login screen{"<!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' xml:lang='en' lang='eng'><head><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' /><title>The Pokemon Asteroid -- Online RPG by Shadow - Made by Shadow</title><style type='text/css'><!--body,td,th {    color: #FF0000;    font-family: Tahoma;    font-size: 9px;    font-weight: bold;}body {    background-color: #000000;}.thead {background: #302226;border: 1px solid #000000;border-bottom: 0px;text-align: center;vertical-align: middle;height: 15px;}.tnav {background: #302226;border: 1px solid #000000;border-bottom: 0px;text-align: center;height: 15px;}.tnav2 {background: #302226;border: 1px solid #000000;border-bottom: 1px solid black;text-align: center;height: 15px;}.news {background: #302226;border: 1px solid #000000;border-bottom: 1px solid #000000;text-align: center;height: 15px;}.banner {border-bottom: 0px;}.dis {border-top: 0px;}.con {border-top: 0px;border-bottom: 0px;}.party {background: #302226;border: 1px solid #000000;border-bottom: 0px;text-align: center;height: 25px;}a:link {    color: #990000;    text-decoration: none;}a:visited {    text-decoration: none;    color: #990000;}a:active {    text-decoration: none;    color: #FFFFFF;}.style1 {color: #FFFFFF}--></style></head><body><table align='center' width='200' height='247' border='0' cellpadding='0' cellspacing='0' bordercolor='#FF0000'>  <tr>    <td align='left' valign='top'><table width='802' height='120' border='1' cellpadding='0' cellspacing='0' bordercolor='#FF0000' class='banner'>      <tr>        <th background='http://i286.photobucket.com/albums/ll84/ChidoriSoul/BetterAsteroidBanner.png?t=1243111409' scope='col'> </th>      </tr>    </table>      <table width='802' height='120' border='1' cellpadding='0' cellspacing='0' bordercolor='#FF0000' class='con'>        <tr><!--- Ads --><div style='text-align: center'><script type='text/javascript'><!--google_ad_client = 'pub-4468899317544238';/* TPARPG */google_ad_slot = '0388012058';google_ad_width = 728;google_ad_height = 90;//--></script><script type='text/javascript'src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script></div><!--- End of Ads --><!--- Left Nav -->                   <th width='122' align='center' valign='top' bgcolor='#302226' scope='row'>                    <div class='thead style1' id='thead'> <font color='limegreen'>General Options</font> </div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/index.php'><font color='blue'>Index</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/register.php'><font color='blue'>Register</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/login.php'><font color='blue'>Login</font></a></div>                    <div class='thead style1' id='thead'> <font color='limegreen'>Miscellaneous</font> </div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/about.php'><font color='blue'>About TPA</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/storyline.php'><font color='blue'>Storyline</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/chatbox.php'><font color='blue'>Chatbox</font></a></div>          <div class='tnav'> <a href='http://www.punbb-hosting.com/forums/TPA_Forums/index.php'><font color='blue'>Forum</font></a></div>                    <div class='thead style1' id='thead'> <font color='limegreen'>Statistics</font> </div>          <div class='tnav'> <font color='blue'>Total Users: 0</font></div>                     </th><!--- End Of Left Nav --> <th width='520 align='center' valign='top' bgcolor='#302226' scope='row'>          <div class='news' id='thead'> Index </div>                   <br /><br/><table width='100%' border='1'><tr><th>News</th></tr><tr><td width='100%'><center><strong>Welcome to The Pokemon Asteroid RPG!</strong></center><br/>Welcome to TPARPG. Here you can do many things such as, Search in Legendary Maps, do daily tasks, get the often promotional pokemon, get Daily Prizes, and do many more exciting things.</td></tr></table><!--- Right Nav -->                   <th width='122' align='center' valign='top' bgcolor='#302226' scope='row'>                    <div class='thead style1' id='thead'> <font color='limegreen'>General Options</font> </div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/index.php'><font color='blue'>Index</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/register.php'><font color='blue'>Register</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/login.php'><font color='blue'>Login</font></a></div>                     <div class='thead style1' id='thead'> <font color='limegreen'>Miscellaneous</font> </div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/about.php'><font color='blue'>About TPA</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/storyline.php'><font color='blue'>Storyline</font></a></div>          <div class='tnav'> <a href='http://tparpg.awardspace.co.uk/chatbox.php'><font color='blue'>Chatbox</font></a></div>          <div class='tnav'> <a href='http://www.punbb-hosting.com/forums/TPA_Forums/index.php'><font color='blue'>Forum</font></a></div>                    <div class='thead style1' id='thead'> <font color='limegreen'>Statistics</font> </div>          <div class='tnav'> <font color='blue'>Total Users: 0</font></div>                     </th><!--- End Of Right Nav --><!--- Disclaimer --><table width='765' height='45' border='1' align='center' cellpadding='0' cellspacing='0' bordercolor='#FF0000' backgroundcolor='#302226' class='dis'><tr>    <td align='center' valign='top'><strong>Disclaimer</strong><br />   The Pokémon Asteroid RPG is © owned and coded by Shadow. All sprites are Copyrighted 2009 Pokémon © Nintendo, Game Freak, Creatures Ink all rights reserved.The Asteroid RPG is not affiliated with the organizations listed above or any other organizations that have co-operated or are co-operating in the programming or making of Pokémon. The images are copyright of their respective owners. This RPG is best viewed with Firefox. </td>  </tr></table></a></div><br /><!--- End Of Disclaimer -->";}?>

Link to comment
Share on other sites

Add debug code to your if statements to see what it's doing when you log out. I'm betting that when you log out the cookie still exists but doesn't contain a valid user ID. You're not checking for that.It's also not necessary to bump your own topics, you're not the only person asking questions here.

Link to comment
Share on other sites

This is my logout code

<?php$past = time() - 100;//this makes the time in the past to destroy the cookiesetcookie(ID_my_site, gone, $past);setcookie(Key_my_site, gone, $past);header("Location: login.php");?>

What is the debug code?

Link to comment
Share on other sites

That doesn't destroy the cookie, it just changes the date. The browser won't destroy expired cookies until you close it. If you want to destroy the cookie, set it with an empty value.Debugging involves adding output statements to print things so that you can see what the program is doing as it runs.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...