PC Nerd Posted January 15, 2007 Share Posted January 15, 2007 hi guysim crezating a login scipt, and where i include the crate_cookies inc file.... the file has an error on line 2:"error on line 2, unextepted t_STRING" ( thats as close as i can get, becauase i dont have the script in front of me as i speak, its on a different computer)the line goes:createcookie('User_Name', $User_Name, strtotime() + 30 Minutes); can anyone help me.... P.S. that may not be the right strtotime format date, but on the script it is correct. I understand i will be hard to find where thee error is without the exact code, but im wondering what to look foor in that error....? thanks for any help in advance Link to comment https://forums.phpfreaks.com/topic/34224-creating-cookies-unexpected-string-any-sugestions/ Share on other sites More sharing options...
OOP Posted January 15, 2007 Share Posted January 15, 2007 Hi there,It would be good if you can post the exact code so that we can help you Link to comment https://forums.phpfreaks.com/topic/34224-creating-cookies-unexpected-string-any-sugestions/#findComment-160996 Share on other sites More sharing options...
PC Nerd Posted January 15, 2007 Author Share Posted January 15, 2007 ok, will do asap, i just wanted to know whether this was a common error with creating cookeis, or whether it is specific in my case... thanks anyway. ill submit the code, asap Link to comment https://forums.phpfreaks.com/topic/34224-creating-cookies-unexpected-string-any-sugestions/#findComment-161018 Share on other sites More sharing options...
trq Posted January 15, 2007 Share Posted January 15, 2007 Its a common syntax error. Meens you probbaly left out a ; or something. Link to comment https://forums.phpfreaks.com/topic/34224-creating-cookies-unexpected-string-any-sugestions/#findComment-161020 Share on other sites More sharing options...
PC Nerd Posted January 15, 2007 Author Share Posted January 15, 2007 ok, soz about the lack of coed, here is the code:B_A-Create_Cookies.inc :[code]<?php$User_Name = $_POST['User_Name'];setcookie("User" , $User_Name, strtotime() + 30 minutes);setcookie(S_Points, $Cookie_Create['S_Points'], strtotime() + 30 minutes);setcookie(A_Points, $Cookie_Create[A_Points'], strtotime() + 30 minutes);setcookie(G_Points, $Cookie_Create['G_Points'], strtotime() + 30 minutes);setcookie(Points, $Cookie_Create['Points'], strtotime() + 30 minutes);setcookie(Moves, $Cookie_Create['Moves'], strtotime() + 30 minutes);setcookie(Resources, $Cookie_Create['Resources'], strtotime() + 30 minutes);setcookie(Attack, $Cookie_Create['Attack'], strtotime() + 30 minutes);setcookie(Power, $Cookie_Create['Power'], strtotime() + 30 minutes);setcookie(Logged_In, YES);#$_COOKIE[User]#$_COOKIE[Logged_In]#$_COOKIE[S_Points]#$_COOKIE[A_Points]#$_COOKIE[G_Points]#$_COOKIE[Points]#$_COOKIE[Moves]#$_COOKIE[Resources]#$_COOKIE[Attack]#$_COOKIE[Defense]#$_COOKIE[Power]?>[/code]B_A-Login1.php :[code]<?php include("inc_files/B_A-Ext_Side_Links.inc"); ?></td><td class = 'centre'><?phpinclude("inc_files/Database_link.inc");if(empty($_POST['User_Name']) || empty($_POST['Password']) || empty($_POST['Valid'])) { die("ERROR 1 You have entered . Click <a href = 'B_A-Home.php' alt = 'Home'>here</a> to return to the Home Page.");}require("inc_files/Login_Pics.inc");$img_post_valid = $_POST['IMG_Valid'];$Image_Validate = $IMAGES["B_A-Login_$img_post_valid"];if($_POST['IMG_Valid'] != $Image_Validate) { die("ERROR 2 You did not type in the correct validation image. Click <a href = 'B_A-Home.php' alt = 'Home'>here</a> to return to the Home Page.");}$SQL_Login = "SELECT User_Name, `Password` FROM General_Stats WHERE User_Name = '".$_POST['User_Name']."'";$Login_Query = mysqli_query($DB_Server, $SQL_Login);if(empty($Login_Query)) { die("ERROR 3 There was an error in the Database. You have not been logged in. Click <a href = 'B_A-Home.php' alt = 'Home'>here</a> to return to the Home Page.");#.mysqli_error($Login_Query));}$DB_Login = mysqli_fetch_array($Login_Query);if(empty($DB_Login)) { die("ERROR 4 There was an error in the Database. You have not been logged in. Click <a href = 'B_A-Home.php' alt = 'Home'>here</a> to return to the Home Page.");#.mysqli_error($DB_Login));}[color=red]include("inc_files/B_A-Create_Cookies.inc");[/color]#echo "<form name = 'Login_Relocation' action = 'B_A-Base.php' method = 'POST'>\n";#echo "<input type = 'button' name = 'relocation' value = 'Play Battle-Ages'>\n";#echo "</form>";echo "<a href = 'B_A-Base.php' alt = 'Base'>Player Battle-Ages</a>\n";?>[/code]ive highlighted the relevent code in the login script, in red so its clear where the error might be...thanks for your help Link to comment https://forums.phpfreaks.com/topic/34224-creating-cookies-unexpected-string-any-sugestions/#findComment-161028 Share on other sites More sharing options...
kobmat Posted January 15, 2007 Share Posted January 15, 2007 This is wrong createcookie('User_Name', $User_Name, strtotime() + 30 Minutes); //Syntax errorit should becreatecookie('User_Name', $User_Name, strtotime("+ 30 Minutes") ); Link to comment https://forums.phpfreaks.com/topic/34224-creating-cookies-unexpected-string-any-sugestions/#findComment-161050 Share on other sites More sharing options...
PC Nerd Posted January 17, 2007 Author Share Posted January 17, 2007 thanks, that got rid of the error, now im getting the error that says cannot send header information, output started at......are cookies header documents........ if so if im only creating variables and testing them before the cookies are created, does that count as being data output, im not echo ing anything . basically where you can see the if's testing empty fields.... im replacing them with variables stating the error, then id if( )and run the cookies if there were no errors.your help is much appreciated, PC NERd Link to comment https://forums.phpfreaks.com/topic/34224-creating-cookies-unexpected-string-any-sugestions/#findComment-162649 Share on other sites More sharing options...
PC Nerd Posted January 17, 2007 Author Share Posted January 17, 2007 ive tried changing so that there is no output, but it now says that the line of php that opens the php code: "<?php" is where the output starts, but the line after that is the include file that creates the cookies. any suggestions, or would this best be placed under a new topic Link to comment https://forums.phpfreaks.com/topic/34224-creating-cookies-unexpected-string-any-sugestions/#findComment-162694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.