GameYin Posted April 7, 2008 Share Posted April 7, 2008 Ok I have a login script. I have a syntax error. Once fixed we will be moving onto displaying certain links if they are signed on. I have taken advice and moved to sessions. Here is the website www.gameyin.com/index.php Here is the code relating to it. In index.php. <?php session_start(); $n=$_SESSION['n']; ?> BLAH BLAH MORE CODING STUFF <b><a class="add" href="index.php">Home</a></b> if (empty($_SESSION['n'])) { ?> <a href="register.php">Register</a> <a href="login.php">Login</a> <? }else{ ?> <a href="logout.php">Logout</a> <a href="usercp/index.php">UserCP</a> <? } ?> The }else{ is line 26. Also, I want register/login to display if not signed on, vice versa for logout/usercp. Help? Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/ Share on other sites More sharing options...
GameYin Posted April 8, 2008 Author Share Posted April 8, 2008 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-511888 Share on other sites More sharing options...
GingerRobot Posted April 8, 2008 Share Posted April 8, 2008 Well, you dont re-open your PHP tags prior to this line: if (empty($_SESSION['n'])) { ?> Though that would cause the code to be displayed on screen. Perhaps showing us the actual code would allow us to show you where the error is. Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-511895 Share on other sites More sharing options...
GameYin Posted April 8, 2008 Author Share Posted April 8, 2008 The BLAH BLAH MORE CODING STUFF is just code from the rest of the website, no php there...I provided the actual code. AH didn't notice I didn't reopen it. When I get home, I'll try it. Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-511987 Share on other sites More sharing options...
GameYin Posted April 9, 2008 Author Share Posted April 9, 2008 www.gameyin.com/login.php Here's the error section. <? } mysql_close($l); ?> It worked btw, opening the tags. Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-512789 Share on other sites More sharing options...
Kieran Menor Posted April 9, 2008 Share Posted April 9, 2008 Unexpected $end usually means unclosed brackets. Post the whole code? Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-512795 Share on other sites More sharing options...
GameYin Posted April 9, 2008 Author Share Posted April 9, 2008 Trying to "high-tech" my error messages. Look now... Here's whole code for login.php <?php session_start(); include 'config.php'; $n=$_SESSION['n']; if(isset($_POST['login'])) { $username = trim(addslashes($_POST['username'])); $password = md5(trim($_POST['password'])); $query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array($query); // now we check if they are activated if(mysql_num_rows($query) > 0) { if($row['Activated'] > 0) { $_SESSION['s_logged_n'] = 'true'; $_SESSION['s_username'] = $username; $_SESSION['s_name'] = $row['Name']; header("Location: index.php"); } elseif ($row['Activated'] != 1) { echo ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Error in login | DevPlooth.com</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="Find webmasters, web designers, SEO techs, web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources. Our forum provides a way for people to find web help and support!" /> <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing, seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" /> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div class="body-container"> <div class="body-outer" id="body-outer"> <div class="body-header"> <div class="logo"> <a href="#">DevPlooth.com</a><br /> <small>Forums | Arcade | Tutorials | Web Hosting |</small> </div> <div class="tmenu"> <b><a class="add" href="index.php">Home</a></b> <? if (empty($_SESSION['n'])) { ?> <a href="register.php">Register</a> <a href="login.php">Login</a> <? }else{ ?> <a href="logout.php">Logout</a> <a href="usercp/index.php">UserCP</a> <? } ?> <a href="arcade/index.php">Arcade</a> <a href="tutorials/index.php">Tutorials</a> <a href="forums/index.php">Forums</a> <a href="proxy/index.php">Proxy</a> </div> <div class="search"> <form action="search.php" method="post" style="display:inline;"> <div> <input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" /> <input type="image" src="images/search.gif" /></div> </form> </div> </div> </div> </div> <div class="navbar"> <small>Please browse our tutorials in many languages!</small> <br /> <table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr> <tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr> <tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr> <tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr> <tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr> <tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr> <tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr> <tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr> <tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr> <tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr> <tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr> <tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr> <tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr> <tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr> <tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr> <tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr> <tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr> <tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr> </table> </div> <div class="error"><p>Sorry, you must activate your account first. Please check your email for the email. OR, you entered invalid details <a href="login.php">Try again.</a></p> <p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div> <div id="footer"> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a> © 2008-2009 DevPlooth.com. All rights reserved <a href="http://jigsaw.w3.org/css-validator/"> <img style="border:0;width:70px;height:25px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /> </a> </p> </div> </body> </html> '; } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Error in login | DevPlooth.com</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="Find webmasters, web designers, SEO techs, web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources. Our forum provides a way for people to find web help and support!" /> <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing, seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" /> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div class="body-container"> <div class="body-outer" id="body-outer"> <div class="body-header"> <div class="logo"> <a href="#">DevPlooth.com</a><br /> <small>Forums | Arcade | Tutorials | Web Hosting |</small> </div> <div class="tmenu"> <b><a class="add" href="index.php">Home</a></b> <? if (empty($_SESSION['n'])) { ?> <a href="register.php">Register</a> <a href="login.php">Login</a> <? }else{ ?> <a href="logout.php">Logout</a> <a href="usercp/index.php">UserCP</a> <? } ?> <a href="arcade/index.php">Arcade</a> <a href="tutorials/index.php">Tutorials</a> <a href="forums/index.php">Forums</a> <a href="proxy/index.php">Proxy</a> </div> <div class="search"> <form action="search.php" method="post" style="display:inline;"> <div> <input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" /> <input type="image" src="images/search.gif" /></div> </form> </div> </div> </div> </div> <div class="navbar"> <small>Please browse our tutorials in many languages!</small> <br /> <table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr> <tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr> <tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr> <tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr> <tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr> <tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr> <tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr> <tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr> <tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr> <tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr> <tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr> <tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr> <tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr> <tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr> <tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr> <tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr> <tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr> <tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr> </table> </div> <div class="error"> <p>You must login to view this page. Enter your username and password below and hit submit:</p> <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> <p>Username:<br> <input name="username" type="text" Cid="username"> <p>Password:<br> <input name="password" type="password" id="password"> </p> <p> <input name="login" type="submit" id="login" value="Submit"> </p> </form> <p>Didn't get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> <p>Need an account? <a href="register.php">Click here</a> to register, it's completely free! </p></div> <div id="footer"> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a> © 2008-2009 DevPlooth.com. All rights reserved <a href="http://jigsaw.w3.org/css-validator/"> <img style="border:0;width:70px;height:25px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /> </a> </p> </div> </body> </html> <? } mysql_close($l); ?> Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-512800 Share on other sites More sharing options...
Kieran Menor Posted April 9, 2008 Share Posted April 9, 2008 I couldn't seem to find closing brackets for: <?php if(isset($_POST['login'])) { if(mysql_num_rows($query) > 0) { ?> Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-512809 Share on other sites More sharing options...
GameYin Posted April 9, 2008 Author Share Posted April 9, 2008 Hmm, you are right. So you think I just need to add 2 }'s to the end of my code? Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-512848 Share on other sites More sharing options...
haku Posted April 9, 2008 Share Posted April 9, 2008 You also didn't add a closing quote at the end of this line: <b><a class="add" href="index.php">Home</a></b> Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-512853 Share on other sites More sharing options...
GameYin Posted April 9, 2008 Author Share Posted April 9, 2008 What do you mean haku?? Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-512915 Share on other sites More sharing options...
haku Posted April 9, 2008 Share Posted April 9, 2008 You have an opening echo statement that doesn't close. I assumed you were echoing the whole start of your document, but upon re-looking at it, I think you just screwed up. Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-512988 Share on other sites More sharing options...
GameYin Posted April 9, 2008 Author Share Posted April 9, 2008 No, I closed my echo. Look after </html> Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-513209 Share on other sites More sharing options...
Kieran Menor Posted April 9, 2008 Share Posted April 9, 2008 You need to add 2 }'s where they should be. I can't tell you, though, as I didn't write the code. This is probably one of the situations where one could benefit from having the HTML seperate from the PHP. Your code is quite incomprehensible. Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-513216 Share on other sites More sharing options...
GameYin Posted April 9, 2008 Author Share Posted April 9, 2008 I added 2 }'s but still a syntax error. And I don't think it's unreadable. I can read it quite fine. Ok, I changed my code to... <?php session_start(); include 'config.php'; $n=$_SESSION['n']; if(isset($_POST['login'])) { $username = trim(addslashes($_POST['username'])); $password = md5(trim($_POST['password'])); $query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array($query); // now we check if they are activated if(mysql_num_rows($query) > 0) { if($row['Activated'] > 0) { $_SESSION['s_logged_n'] = 'true'; $_SESSION['s_username'] = $username; $_SESSION['s_name'] = $row['Name']; header("Location: index.php"); } elseif ($row['Activated'] != 1) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Error in login | DevPlooth.com</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="Find webmasters, web designers, SEO techs, web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources. Our forum provides a way for people to find web help and support!" /> <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing, seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" /> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div class="body-container"> <div class="body-outer" id="body-outer"> <div class="body-header"> <div class="logo"> <a href="index.php">DevPlooth.com</a><br /> <small>Forums | Arcade | Tutorials | Web Hosting |</small> </div> <div class="tmenu"> <b><a class="add" href="index.php">Home</a></b> <? if (empty($_SESSION['n'])) { ?> <a href="register.php">Register</a> <a href="login.php">Login</a> <? }else{ ?> <a href="logout.php">Logout</a> <a href="usercp/index.php">UserCP</a> <? } ?> <a href="arcade/index.php">Arcade</a> <a href="tutorials/index.php">Tutorials</a> <a href="forums/index.php">Forums</a> <a href="proxy/index.php">Proxy</a> </div> <div class="search"> <form action="search.php" method="post" style="display:inline;"> <div> <input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" /> <input type="image" src="images/search.gif" /></div> </form> </div> </div> </div> </div> <div class="navbar"> <small>Please browse our tutorials in many languages!</small> <br /> <table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr> <tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr> <tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr> <tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr> <tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr> <tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr> <tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr> <tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr> <tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr> <tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr> <tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr> <tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr> <tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr> <tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr> <tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr> <tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr> <tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr> <tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr> </table> </div> <div class="error"><p>Sorry, you must activate your account first. Please check your email for the email. OR, you entered invalid details <a href="login.php">Try again.</a></p> <p>Didn'."'".'t get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div> <div id="footer"> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a> © 2008-2009 DevPlooth.com. All rights reserved <a href="http://jigsaw.w3.org/css-validator/"> <img style="border:0;width:70px;height:25px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /> </a> </p> </div> </body> </html> <? } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Error in login | DevPlooth.com</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="Find webmasters, web designers, SEO techs, web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources. Our forum provides a way for people to find web help and support!" /> <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing, seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" /> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div class="body-container"> <div class="body-outer" id="body-outer"> <div class="body-header"> <div class="logo"> <a href="index.php">DevPlooth.com</a><br /> <small>Forums | Arcade | Tutorials | Web Hosting |</small> </div> <div class="tmenu"> <b><a class="add" href="index.php">Home</a></b> <? if (empty($_SESSION['n'])) { ?> <a href="register.php">Register</a> <a href="login.php">Login</a> <? }else{ ?> <a href="logout.php">Logout</a> <a href="usercp/index.php">UserCP</a> <? } ?> <a href="arcade/index.php">Arcade</a> <a href="tutorials/index.php">Tutorials</a> <a href="forums/index.php">Forums</a> <a href="proxy/index.php">Proxy</a> </div> <div class="search"> <form action="search.php" method="post" style="display:inline;"> <div> <input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" /> <input type="image" src="images/search.gif" /></div> </form> </div> </div> </div> </div> <div class="navbar"> <small>Please browse our tutorials in many languages!</small> <br /> <table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr> <tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr> <tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr> <tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr> <tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr> <tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr> <tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr> <tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr> <tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr> <tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr> <tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr> <tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr> <tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr> <tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr> <tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr> <tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr> <tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr> <tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr> </table> </div> <div class="error"> <p>You must login to view this page. Enter your username and password below and hit submit:</p> <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> <p>Username:<br> <input name="username" type="text" Cid="username"> <p>Password:<br> <input name="password" type="password" id="password"> </p> <p> <input name="login" type="submit" id="login" value="Submit"> </p> </form> <p>Didn't get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> <p>Need an account? <a href="register.php">Click here</a> to register, it's completely free! </p></div> <div id="footer"> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a> © 2008-2009 DevPlooth.com. All rights reserved <a href="http://jigsaw.w3.org/css-validator/"> <img style="border:0;width:70px;height:25px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /> </a> </p> </div> </body> </html> <? } } } mysql_close($l); ?> But now nothing shows up. www.gameyin.com/login.php Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-513219 Share on other sites More sharing options...
darkfreaks Posted April 9, 2008 Share Posted April 9, 2008 try: <?php session_start(); $n=$_SESSION['n']; ?> BLAH BLAH MORE CODING STUFF <b><a class="add" href="index.php">Home</a></b> <?php if (empty($_SESSION['n'])) { ?> <a href="register.php">Register</a> <a href="login.php">Login</a> <?php }else{ ?> <a href="logout.php">Logout</a> <a href="usercp/index.php">UserCP</a> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-513226 Share on other sites More sharing options...
Kieran Menor Posted April 9, 2008 Share Posted April 9, 2008 You may be able to read your code, it was written by you afterall. Then again... you don't seem to have any overview of what's going on. Not to mention how hard it is for others to read. Also, I think if(isset($_POST['login'])) is pretty much the reason why nothing shows up. Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-513231 Share on other sites More sharing options...
GingerRobot Posted April 9, 2008 Share Posted April 9, 2008 Your closing braces are in the wrong place. ALL of your code (well, bar the first 5 lines) is inside the first if statement. This is why it was not just a simple matter of adding in the closing brackets. You need to go through your code very carefully, and make sense of what it is supposed to be doing where. Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-513235 Share on other sites More sharing options...
GameYin Posted April 9, 2008 Author Share Posted April 9, 2008 Ok, changed things up a bit..Now I have a syntax error again...www.gameyin.com/login.php <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Login | DevPlooth.com</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="Find webmasters, web designers, SEO techs, web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources. Our forum provides a way for people to find web help and support!" /> <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing, seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" /> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div class="body-container"> <div class="body-outer" id="body-outer"> <div class="body-header"> <div class="logo"> <a href="index.php">DevPlooth.com</a><br /> <small>Forums | Arcade | Tutorials | Web Hosting |</small> </div> <div class="tmenu"> <b><a class="add" href="index.php">Home</a></b> <? if (empty($_SESSION['n'])) { ?> <a href="register.php">Register</a> <a href="login.php">Login</a> <? }else{ ?> <a href="logout.php">Logout</a> <a href="usercp/index.php">UserCP</a> <? } ?> <a href="arcade/index.php">Arcade</a> <a href="tutorials/index.php">Tutorials</a> <a href="forums/index.php">Forums</a> <a href="proxy/index.php">Proxy</a> </div> <div class="search"> <form action="search.php" method="post" style="display:inline;"> <div> <input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" /> <input type="image" src="images/search.gif" /></div> </form> </div> </div> </div> </div> <div class="navbar"> <small>Please browse our tutorials in many languages!</small> <br /> <table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr> <tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr> <tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr> <tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr> <tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr> <tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr> <tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr> <tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr> <tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr> <tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr> <tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr> <tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr> <tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr> <tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr> <tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr> <tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr> <tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr> <tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr> </table> </div> <?php include 'config.php'; $n=$_SESSION['n']; if(isset($_POST['login'])) { $username = trim(addslashes($_POST['username'])); $password = md5(trim($_POST['password'])); $query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array($query); // now we check if they are activated if(mysql_num_rows($query) > 0) { if($row['Activated'] > 0) { $_SESSION['s_logged_n'] = 'true'; $_SESSION['s_username'] = $username; $_SESSION['s_name'] = $row['Name']; header("Location: index.php"); } elseif ($row['Activated'] != 1) { echo ' <div class="error"><p>Sorry, you must activate your account first. Please check your email for the email. OR, you entered invalid details <a href="login.php">Try again.</a></p> <p>Didnt get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div> <div id="footer"> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a> © 2008-2009 DevPlooth.com. All rights reserved <a href="http://jigsaw.w3.org/css-validator/"> <img style="border:0;width:70px;height:25px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /> </a> </p> </div> </body> </html> <? } else { echo ' <div class="error"> <p>You must login to view this page. Enter your username and password below and hit submit:</p> <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> <p>Username:<br> <input name="username" type="text" Cid="username"> <p>Password:<br> <input name="password" type="password" id="password"> </p> <p> <input name="login" type="submit" id="login" value="Submit"> </p> </form> <p>Didnt get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> <p>Need an account? <a href="register.php">Click here</a> to register, its completely free! </p></div> <div id="footer"> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a> © 2008-2009 DevPlooth.com. All rights reserved <a href="http://jigsaw.w3.org/css-validator/"> <img style="border:0;width:70px;height:25px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /> </a> </p> </div> </body> </html> <? } } } mysql_close($l); ?> Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-513241 Share on other sites More sharing options...
GameYin Posted April 9, 2008 Author Share Posted April 9, 2008 AH, didn't see the second page, well try looking now. Also, I said before, I'm still learning the sessions things. Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-513243 Share on other sites More sharing options...
Kieran Menor Posted April 9, 2008 Share Posted April 9, 2008 I still say that you should put the HTML in seperate files. This one was very obvious. Observe the changes: </html>'; <? } else { echo ' ... </html>'; Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-513247 Share on other sites More sharing options...
GameYin Posted April 9, 2008 Author Share Posted April 9, 2008 I did all the changes, still syntax error. Here is the updated code <?php session_start(); include 'config.php'; $n=$_SESSION['n']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Login | DevPlooth.com</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="Find webmasters, web designers, SEO techs, web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources. Our forum provides a way for people to find web help and support!" /> <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing, seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" /> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div class="body-container"> <div class="body-outer" id="body-outer"> <div class="body-header"> <div class="logo"> <a href="index.php">DevPlooth.com</a><br /> <small>Forums | Arcade | Tutorials | Web Hosting |</small> </div> <div class="tmenu"> <b><a class="add" href="index.php">Home</a></b> <? if (empty($_SESSION['n'])) { ?> <a href="register.php">Register</a> <a href="login.php">Login</a> <? }else{ ?> <a href="logout.php">Logout</a> <a href="usercp/index.php">UserCP</a> <? } ?> <a href="arcade/index.php">Arcade</a> <a href="tutorials/index.php">Tutorials</a> <a href="forums/index.php">Forums</a> <a href="proxy/index.php">Proxy</a> </div> <div class="search"> <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> style="display:inline;"> <div> <input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" /> <input type="image" src="images/search.gif" /></div> </form> </div> </div> </div> </div> <div class="navbar"> <small>Please browse our tutorials in many languages!</small> <br /> <table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr> <tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr> <tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr> <tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr> <tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr> <tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr> <tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr> <tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr> <tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr> <tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr> <tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr> <tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr> <tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr> <tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr> <tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr> <tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr> <tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr> <tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr> </table> </div> <?php if(isset($_POST['login'])) { $username = trim(addslashes($_POST['username'])); $password = md5(trim($_POST['password'])); $query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array($query); // now we check if they are activated if(mysql_num_rows($query) > 0) { if($row['Activated'] > 0) { $_SESSION['s_logged_n'] = 'true'; $_SESSION['s_username'] = $username; $_SESSION['s_name'] = $row['Name']; header("Location: index.php"); } elseif ($row['Activated'] != 1) { echo ' <div class="error"><p>Sorry, you must activate your account first. Please check your email for the email. OR, you entered invalid details <a href="login.php">Try again.</a></p> <p>Didnt get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div> <div id="footer"> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a> © 2008-2009 DevPlooth.com. All rights reserved <a href="http://jigsaw.w3.org/css-validator/"> <img style="border:0;width:70px;height:25px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /> </a> </p> </div> </body> </html> } else { echo ' <div class="error"> <p>You must login to view this page. Enter your username and password below and hit submit:</p> <form method="post" action="<?= $_SERVER['PHP_SELF'] ?>"> <p>Username:<br> <input name="username" type="text" Cid="username"> <p>Password:<br> <input name="password" type="password" id="password"> </p> <p> <input name="login" type="submit" id="login" value="Submit"> </p> </form> <p>Didnt get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> <p>Need an account? <a href="register.php">Click here</a> to register, its completely free! </p></div> <div id="footer"> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a> © 2008-2009 DevPlooth.com. All rights reserved <a href="http://jigsaw.w3.org/css-validator/"> <img style="border:0;width:70px;height:25px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /> </a> </p> </div> </body> </html>'; } } } mysql_close($l); ?> Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-513250 Share on other sites More sharing options...
Kieran Menor Posted April 9, 2008 Share Posted April 9, 2008 You forgot '; </html>'; } else { echo ' <div class="error"> Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-513254 Share on other sites More sharing options...
GameYin Posted April 9, 2008 Author Share Posted April 9, 2008 Ok, there was 1 more syntax error like that one, fixed it. Thanks. Though www.gameyin.com/login.php Form doesn't show up. And I'm not logged on. <?php session_start(); include 'config.php'; $n=$_SESSION['n']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Login | DevPlooth.com</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="Find webmasters, web designers, SEO techs, web developers, designers PHP experts, html experts, javascript experts, css experts, SEO advice, marketing tips and resources. Our forum provides a way for people to find web help and support!" /> <meta name="keywords" content="webmaster forum, web design, web developers, developer forum, web forum, php experts, web marketing, seo experts, database experts, support forum, programming, html, css, javascript, mysql, sql, web" /> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div class="body-container"> <div class="body-outer" id="body-outer"> <div class="body-header"> <div class="logo"> <a href="index.php">DevPlooth.com</a><br /> <small>Forums | Arcade | Tutorials | Web Hosting |</small> </div> <div class="tmenu"> <b><a class="add" href="index.php">Home</a></b> <? if (empty($_SESSION['n'])) { ?> <a href="register.php">Register</a> <a href="login.php">Login</a> <? }else{ ?> <a href="logout.php">Logout</a> <a href="usercp/index.php">UserCP</a> <? } ?> <a href="arcade/index.php">Arcade</a> <a href="tutorials/index.php">Tutorials</a> <a href="forums/index.php">Forums</a> <a href="proxy/index.php">Proxy</a> </div> <div class="search"> <form method="post" action="login.php" style="display:inline;"> <div> <input type="text" name="search" class="input-search" value="Enter your Search Query" onblur="if(this.value=='') this.value='Enter your Search Query';" onfocus="if(this.value=='Enter your Search Query') this.value='';" /> <input type="image" src="images/search.gif" /></div> </form> </div> </div> </div> </div> <div class="navbar"> <small>Please browse our tutorials in many languages!</small> <br /> <table id="navbar"><tr><td>»<a href="tutorials/xhtml/index.html">(X)HTML</a></td></tr> <tr><td>»<a href="tutorials/css/index.html">CSS</a></td></tr> <tr><td>»<a href="tutorials/javascript/index.html">JavaScript</a></td></tr> <tr><td>»<a href="tutorials/php/index.html">PHP</a></td></tr> <tr><td>»<a href="tutorials/asp/index.html">ASP</a></td></tr> <tr><td>»<a href="tutorials/aspnet/index.html">ASP.NET</a></td></tr> <tr><td>»<a href="tutorials/coldfusion/index.html">ColdFusion</a></td></tr> <tr><td>»<a href="tutorials/mysql/index.html">MySQL</a></td></tr> <tr><td>»<a href="tutorials/apache/index.html">Apache</a></td></tr> <tr><td>»<a href="tutorials/dhtml/index.html">DHTML</a></td></tr> <tr><td>»<a href="tutorials/ajax/index.html">AJAX</a></td></tr> <tr><td>»<a href="tutorials/xml/index.html">XML</a></td></tr> <tr><td>»<a href="tutorials/xslt/index.html">XSLT</a></td></tr> <tr><td>»<a href="tutorials/actionscript/index.html">ActionScript</a></td></tr> <tr><td>»<a href="tutorials/vbscript/index.html">VBScript</a></td></tr> <tr><td>»<a href="tutorials/vb/index.html">VB</a></td></tr> <tr><td>»<a href="tutorials/python/index.html">Python</a></td></tr> <tr><td>»<a href="tutorials/rubyonrails/index.html">Ruby On Rails</a></td></tr> </table> </div> <?php if(isset($_POST['login'])) { $username = trim(addslashes($_POST['username'])); $password = md5(trim($_POST['password'])); $query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array($query); // now we check if they are activated if(mysql_num_rows($query) > 0) { if($row['Activated'] > 0) { $_SESSION['s_logged_n'] = 'true'; $_SESSION['s_username'] = $username; $_SESSION['s_name'] = $row['Name']; header("Location: index.php"); } elseif ($row['Activated'] != 1) { echo ' <div class="error"><p>Sorry, you must activate your account first. Please check your email for the email. OR, you entered invalid details <a href="login.php">Try again.</a></p> <p>Didnt get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p></div> <div id="footer"> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a> © 2008-2009 DevPlooth.com. All rights reserved <a href="http://jigsaw.w3.org/css-validator/"> <img style="border:0;width:70px;height:25px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /> </a> </p> </div> </body> </html>'; } else { echo ' <div class="error"> <p>You must login to view this page. Enter your username and password below and hit submit:</p> <form method="post" action="login.php"> <p>Username:<br> <input name="username" type="text" Cid="username"> <p>Password:<br> <input name="password" type="password" id="password"> </p> <p> <input name="login" type="submit" id="login" value="Submit"> </p> </form> <p>Didnt get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> <p>Need an account? <a href="register.php">Click here</a> to register, its completely free! </p></div> <div id="footer"> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Strict" height="25" width="70" /></a> © 2008-2009 DevPlooth.com. All rights reserved <a href="http://jigsaw.w3.org/css-validator/"> <img style="border:0;width:70px;height:25px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /> </a> </p> </div> </body> </html>'; } } } mysql_close($l); ?> Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-513257 Share on other sites More sharing options...
GingerRobot Posted April 9, 2008 Share Posted April 9, 2008 Most of your code is still inside this if statement: if(isset($_POST['login'])) { Positioning of braces isn't something you can just hope for the best with - change the position of one and it changes the logic of your code completely. Quote Link to comment https://forums.phpfreaks.com/topic/100031-solved-syntax-error-then-moving-to-sessions/#findComment-513265 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.