Jump to content

creating cookies, unexpected string... ??any sugestions?


PC Nerd

Recommended Posts

hi guys

im 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
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'>


<?php

include("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
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
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.