dolcezza Posted November 27, 2007 Share Posted November 27, 2007 When I try to use this code I get a line error on line 2. "Parse error: syntax error, unexpected T_STRING in ../login.php on line 2" All that is on line 2 is ob_start(); Any help? Greatly appreciated. <? php ob_start(); require_once("db_connect.php"); if isset($_SESSION['username']) && isset($_SESSION['password']) { // redirect to users profile header("Location: https://www.garegivingsocal.com/members.php"); } // end if logged in // if submit button is pressed if(isset($_POST['submit'])) { if(!$_POST['username']) die("Error: You must enter your username to log in."); if(!$_POST['password']) die("Error: You must enter a password to log in."); //set cookie if checked if(!empty$($_POST['stay_in])) { $joined =''.$_POST['username'].'[]'.md5($_POST['password']).''; setcookie('login_cookie', $joined, 2147483647, '/', .www.caregivingsocal.com'); } // end if //verify user $get_user = mysql_query("SELECT * FROM 'mem' WHERE username = '".$_POST['username']."' AND user_password = '".md5($_POST['password'])."'"); $q = mysql_fetch_object($get_user); if(!$q) die("Login Failure: Please verify your username and password are correct."); // set session variables $_SESSION['logged in'] = 1; $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['password']; session_write_close(); Header("Location: https://www.caregivingsocal.com/loggedin.php"); } else { //show login form ?> <form name="login" method="post" action="<?$_SERVER['PHP_SELF']; ?>"> <table> <tr><td>Username:</td><td><input type="text" id="username" name="username"></td></tr> <tr><td>Password:</td><td><input type="password" id="password" name="password"></td></tr> <tr><td>Submit: <input type="submit" value="submit" name="submit" id="submit"></td></tr> <tr><td><input type="checkbox" name="stay_in[]" checked="yes">Remember Me</td></tr></table></form> <? } // end else ?> Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 27, 2007 Share Posted November 27, 2007 whats the error? or maybe this <? php to <?php Quote Link to comment Share on other sites More sharing options...
dolcezza Posted November 27, 2007 Author Share Posted November 27, 2007 nope still same error: Parse error: syntax error, unexpected T_STRING in ../login.php on line 2 Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 27, 2007 Share Posted November 27, 2007 this line if isset($_SESSION['username']) && isset($_SESSION['password']) { to if (isset($_SESSION['username']) && isset($_SESSION['password'])) { Quote Link to comment Share on other sites More sharing options...
dolcezza Posted November 27, 2007 Author Share Posted November 27, 2007 still same error. I get the same exact thing on another page too. Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 27, 2007 Share Posted November 27, 2007 can you post the whole error and the page that the error is pointing out? Quote Link to comment Share on other sites More sharing options...
dolcezza Posted November 27, 2007 Author Share Posted November 27, 2007 above is the code for the whole page so far. the page is http://caregivingsocal.com/php/login.php The error is Parse error: syntax error, unexpected T_STRING in /home/care/public_html/php/login.php on line 2 This is the code for the other page I get the same exact error: <? ob_start(); session_start( ); require_once("db_connect.php"); //check cookie if ($_SESSION['logged_in'] != 1 && isset($_COOKIE['login_cookie'])) { list($user, $pass) = explode('[]', $_COOKIE['login_cookie']); $qu = mysql_query("SELECT `user_password` FROM `mem` WHERE `username` = '".addslashes($user)."'"); if (mysql_num_rows($qu) == 1) { $passw = mysql_fetch_object($qu); if ($passw->user_password == $pass) { $_SESSION['logged_in'] = 1; $_SESSION['username'] = $user; $_SESSION['password'] = $pass; } } } if(!isset($_SESSION['username']) && !isset($_SESSION['password'])) { $_SESSION['logged_in'] = 0; $user = "Guest"; } ?> Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 27, 2007 Share Posted November 27, 2007 damn you have tons of syntax error ... <? ob_start(); require_once("db_connect.php"); if (isset($_SESSION['username']) && isset($_SESSION['password'])) { header("Location: https://www.garegivingsocal.com/members.php"); } if(isset($_POST['submit'])) { if(!$_POST['username']) die("Error: You must enter your username to log in."); if(!$_POST['password']) die("Error: You must enter a password to log in."); //set cookie if checked if(!empty$($_POST['stay_in'])) { $joined =''.$_POST['username'].'[]'.md5($_POST['password']).''; setcookie('login_cookie', $joined, 2147483647, '/','www.caregivingsocal.com'); } // end if //verify user $get_user = mysql_query("SELECT * FROM 'mem' WHERE username = '".$_POST['username']."' AND user_password = '".md5($_POST['password'])."'"); $q = mysql_fetch_object($get_user); if(!$q) die("Login Failure: Please verify your username and password are correct."); // set session variables $_SESSION['logged in'] = 1; $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['password']; session_write_close(); Header("Location: https://www.caregivingsocal.com/loggedin.php"); } else { //show login form ?> <form name="login" method="post" action="<?$_SERVER['PHP_SELF']; ?>"> <table> <tr><td>Username:</td><td><input type="text" id="username" name="username"></td></tr> <tr><td>Password:</td><td><input type="password" id="password" name="password"></td></tr> <tr><td>Submit: <input type="submit" value="submit" name="submit" id="submit"></td></tr> <tr><td><input type="checkbox" name="stay_in[]" checked="yes">Remember Me</td></tr></table></form> <? } // end else ?> try that and lets see what going to be the next error Quote Link to comment Share on other sites More sharing options...
dolcezza Posted November 27, 2007 Author Share Posted November 27, 2007 still same exact error. Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 27, 2007 Share Posted November 27, 2007 <? echo 'test teng'; require_once("db_connect.php"); if (isset($_SESSION['username']) && isset($_SESSION['password'])) { header("Location: https://www.garegivingsocal.com/members.php"); } if(isset($_POST['submit'])) { if(!$_POST['username']) die("Error: You must enter your username to log in."); if(!$_POST['password']) die("Error: You must enter a password to log in."); //set cookie if checked if(!empty$($_POST['stay_in'])) { $joined =''.$_POST['username'].'[]'.md5($_POST['password']).''; setcookie('login_cookie', $joined, 2147483647, '/','www.caregivingsocal.com'); } // end if //verify user $get_user = mysql_query("SELECT * FROM 'mem' WHERE username = '".$_POST['username']."' AND user_password = '".md5($_POST['password'])."'"); $q = mysql_fetch_object($get_user); if(!$q) die("Login Failure: Please verify your username and password are correct."); // set session variables $_SESSION['logged in'] = 1; $_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['password']; session_write_close(); Header("Location: https://www.caregivingsocal.com/loggedin.php"); } else { //show login form ?> <form name="login" method="post" action="<?$_SERVER['PHP_SELF']; ?>"> <table> <tr><td>Username:</td><td><input type="text" id="username" name="username"></td></tr> <tr><td>Password:</td><td><input type="password" id="password" name="password"></td></tr> <tr><td>Submit: <input type="submit" value="submit" name="submit" id="submit"></td></tr> <tr><td><input type="checkbox" name="stay_in[]" checked="yes">Remember Me</td></tr></table></form> <? } // end else ?> try that and let me know what happen or show me the page! Quote Link to comment Share on other sites More sharing options...
dolcezza Posted November 28, 2007 Author Share Posted November 28, 2007 still the same error http://caregivingsocal.com/php/login.php Thank you for trying, I am new at this and am trying to learn by following tutorials. It's greatly appreciated! Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 28, 2007 Share Posted November 28, 2007 heres what my conclusions you aren't really updating the files as you can see i have place there my name at the top what ever happen as long as error reporting is not off that should echo my name...and for sure error reporting is not off .. check if you really uploading it correctly.. Quote Link to comment Share on other sites More sharing options...
dolcezza Posted November 28, 2007 Author Share Posted November 28, 2007 You were right. I went into cpanel and the old file was there. I have no idea why, I've uploaded thousands of pages before and never had that happen (using dreamweaver) Now the error is on line 12 Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 28, 2007 Share Posted November 28, 2007 lol you waste my precious time... if(!empty$($_POST['stay_in'])) { to if(!empty($_POST['stay_in'])) { i guess try to fix it first then get back if you cant do it... Quote Link to comment Share on other sites More sharing options...
dolcezza Posted November 28, 2007 Author Share Posted November 28, 2007 sorry..I saw that right after I hit post...it's fixed. Now it says line 3 require_once("db_connect.php"); I don't see why it wouldn't have said that before... this can get confusing when you don't have the eye yet! :-\ Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 28, 2007 Share Posted November 28, 2007 if you cant figure out the errors please always post here the error message! Quote Link to comment Share on other sites More sharing options...
dolcezza Posted November 28, 2007 Author Share Posted November 28, 2007 sorry, rushing and getting frustrated. I'll take a breathe.... Parse error: syntax error, unexpected T_VARIABLE in /home/care/public_html/php/db_connect.php on line 3 Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 28, 2007 Share Posted November 28, 2007 post here that page "db_connect.php " or check you might missed this in that line ) Quote Link to comment Share on other sites More sharing options...
dolcezza Posted November 28, 2007 Author Share Posted November 28, 2007 I found the mistake in that file... I didn't know the error report could mean another file, thanks for the very important info!! I'm sure I'll come across that alot. I guess you learn more from mistakes than anything else.. the tutorials don't tell you what not to do. Let's see how far I can get now... Thanks so much! Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 28, 2007 Share Posted November 28, 2007 Quote Link to comment 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.