Btown2 Posted May 5, 2008 Share Posted May 5, 2008 maybe you guys can tell me why this is failing. <?php session_start(); if(isset($_SESSION['username']) && isset($_SESSION['password'])) { $username = $_SESSION['username']; $password = md5($_SESSION['password']); include dbconnect.php; $query = "select * from users where username = '$username'"; $result = mysql_query($query) or die("Error with session login name/password."); $user = mysql_fetch_row($result); if($password == $user[1]) $_SESSION['loggedin'] = "true"; else $_SESSION['loggedin'] = "false"; include 'closedb.php'; } else { $_SESSION['loggedin'] = "false"; } ?> <!DOCTYPE HTML PUBLIC "-//ISU HTML 4.01 Transitional//EN"> <html> <head> <title>Brayton Thompson</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="myCSS.css" rel="stylesheet" type="text/css"> </head> <body> <div id="navigation"> <h2>Site Map</h2> <ul> <?php include 'dbconnect.php'; $query = "select * from site_map"; $result = mysql_query($query) or die("Error getting links from MySQL"); $num_rows = mysql_num_rows($result); $i = 0; for(;$i < $num_rows; $i++) { $row = mysql_fetch_row($result); $anchor = $row[0]; $url = $row[1]; echo ("<li><a href='$url'>$anchor</a></li>"); } include 'closedb.php'; ?> </ul> <br> <h2>Helpful Links</h2> <ul> <?php include 'dbconnect.php'; $query = "select * from helpful_links"; $result = mysql_query($query) or die("Error getting links from MySQL"); $num_rows = mysql_num_rows($result); $i = 0; for(;$i < $num_rows; $i++) { $row = mysql_fetch_row($result); $anchor = $row[0]; $url = $row[1]; echo("<li><a href='$url'>$anchor</a></li>"); } include 'closedb.php'; ?> </u1> </div> <div id="centerDoc"> <?php if($_SESSION['loggedin'] == "true") { echo ("<h1>Welcome $_SESSION['username']!</h1>"); } else { echo ("<h1>Welcome! (please log in)</h1>"); } echo ("$_SESSION['loggedin']"); ?> <p> Hello! Welcome to my site. I am Brayton Thompson, a Junior at Indiana State University majoring in Computer Science. </p> </div> </body> </html> Thanks in advance for the help. Link to comment https://forums.phpfreaks.com/topic/104135-solved-grrr-2-hrs-and-still-cant-find-my-error/ Share on other sites More sharing options...
joecooper Posted May 5, 2008 Share Posted May 5, 2008 what line and error does it say? Link to comment https://forums.phpfreaks.com/topic/104135-solved-grrr-2-hrs-and-still-cant-find-my-error/#findComment-533136 Share on other sites More sharing options...
tronicsmasta Posted May 5, 2008 Share Posted May 5, 2008 change this: <?php if($_SESSION['loggedin'] == "true") { echo ("<h1>Welcome $_SESSION['username']!</h1>"); } else { echo ("<h1>Welcome! (please log in)</h1>"); } echo ("$_SESSION['loggedin']"); ?> to this: <?php if($_SESSION['loggedin'] == "true") { echo ("<h1>Welcome ".$_SESSION['username']."!</h1>"); } else { echo ("<h1>Welcome! (please log in)</h1>"); } echo ($_SESSION['loggedin']); ?> when using echo, you need to seperate functions of php with text... basically by following this format: echo "blah text".function['blah']."more text"; try that and get back to us Link to comment https://forums.phpfreaks.com/topic/104135-solved-grrr-2-hrs-and-still-cant-find-my-error/#findComment-533138 Share on other sites More sharing options...
tronicsmasta Posted May 5, 2008 Share Posted May 5, 2008 Also, you might want to check out this program http://www.mpsoftware.dk/phpdesigner.php its handy in finding out syntax errors and inserting functions and stuff its my favorite lol Link to comment https://forums.phpfreaks.com/topic/104135-solved-grrr-2-hrs-and-still-cant-find-my-error/#findComment-533142 Share on other sites More sharing options...
Btown2 Posted May 5, 2008 Author Share Posted May 5, 2008 change this: <?php if($_SESSION['loggedin'] == "true") { echo ("<h1>Welcome $_SESSION['username']!</h1>"); } else { echo ("<h1>Welcome! (please log in)</h1>"); } echo ("$_SESSION['loggedin']"); ?> to this: <?php if($_SESSION['loggedin'] == "true") { echo ("<h1>Welcome ".$_SESSION['username']."!</h1>"); } else { echo ("<h1>Welcome! (please log in)</h1>"); } echo ($_SESSION['loggedin']); ?> when using echo, you need to seperate functions of php with text... basically by following this format: echo "blah text".function['blah']."more text"; try that and get back to us Wow, that was it. Thank you so much. Link to comment https://forums.phpfreaks.com/topic/104135-solved-grrr-2-hrs-and-still-cant-find-my-error/#findComment-533144 Share on other sites More sharing options...
Btown2 Posted May 5, 2008 Author Share Posted May 5, 2008 Also, you might want to check out this program http://www.mpsoftware.dk/phpdesigner.php its handy in finding out syntax errors and inserting functions and stuff its my favorite lol Ok ill give it a whorl, thnx for the info Link to comment https://forums.phpfreaks.com/topic/104135-solved-grrr-2-hrs-and-still-cant-find-my-error/#findComment-533145 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.