dlyles Posted November 30, 2006 Share Posted November 30, 2006 I've searched the site and saw plenty of things on cookies, but I'm still getting something wrong. I'm getting the following errorParse error: syntax error, unexpected T_STRING in /var/opt/data/rgbdata/apache/htdocs/checklogin.php on line 26from this:[code]setcookie('".$_POST['myusername']."',$myusername);[/code] Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 30, 2006 Share Posted November 30, 2006 Why the two sets of quotes? Just do this:[code]setcookie($_POST['myusername'],$myusername);[/code] Quote Link to comment Share on other sites More sharing options...
taith Posted November 30, 2006 Share Posted November 30, 2006 wonderful thing bout variables, once data is set, " ' are no longer necessary... you can use em... but not necessary...[code]$time = 60 * 60 * 24 * 60 + time(); #two monthssetcookie($_POST['myusername'],$myusername,$time);setcookie("$_POST['myusername']","$myusername","$time"); #same thing, dont use ' or it'll take the $time as a string, not a variable.[/code] Quote Link to comment Share on other sites More sharing options...
dlyles Posted November 30, 2006 Author Share Posted November 30, 2006 Thanks. I used[code]setcookie($_POST['myusername'],$myusername,$time);[/code]and got the same errorWarning: Cannot modify header information - headers already sent by (output started at /var/opt/data/rgbdata/apache/htdocs/checklogin.php:2) in /var/opt/data/rgbdata/apache/htdocs/checklogin.php on line 27 Quote Link to comment Share on other sites More sharing options...
taith Posted November 30, 2006 Share Posted November 30, 2006 aah... you have to put that BEFORE anything is outputed (echo/print)... Quote Link to comment Share on other sites More sharing options...
dlyles Posted November 30, 2006 Author Share Posted November 30, 2006 Yeah, I did, however...[code]$myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";$result=mysql_query($sql);$count=mysql_num_rows($result);if($count==1){// Register $myusername, $mypassword and redirect to file "mainpage.php"$time = 60 * 60 * 24 * 60 + time(); #two monthssetcookie($_POST['myusername'],$myusername,$time);$_Session["username"]=$_POST['myusername'];$_Session["password"]=$_POST['mypassword'];// session_register("myusername");// session_register("mypassword"); //echo "<meta http-equiv='Refresh' content='0; url=mainpage.php'>";exit; //header("location:mainpage.php");}else {echo "Wrong Username or Password";}?>[/code] Quote Link to comment Share on other sites More sharing options...
taith Posted November 30, 2006 Share Posted November 30, 2006 ok... and whats on line 27 of checklogin.php? Quote Link to comment Share on other sites More sharing options...
dlyles Posted December 1, 2006 Author Share Posted December 1, 2006 I fixed it. I had to remove whitespaces, etdc. 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.