Cookies are now driving me crazy....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have some code which I'll paste at the end of the e-mail that is throwing an error and I can't seem to find where the error is... Here is the error: "[Wed Nov 28 15:03:19 2007] [error] PHP Parse error: syntax error, unexpected '{' in /Volumes/RAIDer/webserver/Documents/ OLDB/customer/test/detectuser.php on line 27"

Now... I realize that it's not expecting a '{' on line 27... But I checked the brackets, and from what I can tell, they all look balanced...Any help is appreciated!



<?php
include('defaults.php');
include('dbconnect.php');
 //see if detectuser.php has been required, not URL’d.
if ($legal_require_php!=1234) exit;
// setup global variable $global_user_id, set it to 0, which means no user as auto_increment IDs in MySQL begin with 1
 $global_user_id= 0;
 // now, check if user’s computer has the cookie set
if (isset($_COOKIE['cookiename'])) {
$cookieval= $_COOKIE['cookiename'];
//now parse the ID:LOGCODE value in cooke via explode() function
$cookieparsed= explode (":", $cookieval);
// $cookie_uid will hold user’s id
// $cookie_code will hold user’s last reported logcode
$cookie_uid= $cookieparsed[0];
$cookie_code= $cookieparsed[1];
  // ensure that ID from cookie is a numeric value
if (is_numeric($cookie_uid)) {
//now, find the user via his ID
$res= mysql_query("SELECT logcode FROM MainLogin WHERE id=$cookie_uid");
// no die() this time, we will redirect if error occurs
if ($res) {
 // now see if user’s id exists in database
   if (mysql_num_rows($res,0) {
  $logcode_in_base= mysql_result($res, 0);
  // now compare LOGCODES in cookie against the one in database
  if ($logcode_in_base == $cookie_code) {
   // if valid, generate new logcode and update database
   $newcode= md5(func_generate_string());
$res= mysql_query("UPDATE MainLogin SET logcode='$newcode' WHERE id=$cookie_uid");
   // setup new cookie (replace the old one)
   $newval= "$cookie_uid:$newcode";
setcookie("cookiename", $newval, time() + 300, "/oldb/", ".raoset.com");
   // finally, setup global var to reflect user’s id
   $global_user_id= $cookie_uid;
  } else {
   // redirect if logcodes are not equal
   echo "Logcodes are not equal";
  }
 } else {
  // redirect if user ID does not exist in database
  echo "User not in database";
 }
 } else {
  // redirect in case of database error
  echo "database error";
 }
} else {
 // redirect if user ID in cookie not numeric
 echo "Cookie not numeric";
}
 }
?>
--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
japruim@xxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux