Jump to content

Parse error: syntax error, unexpected T_STRING


phpdonut

Recommended Posts

Hi i' pretty new to php and keep gettin this error..... Parse error: syntax error, unexpected T_STRING on line 40

i'm pretty sure line 40 is okay it ight be something before hand.....any ideas??

 

oh btw line 40 is :

$res=“UPDATE my_users SET logcode='$newcode' WHERE id=$cookie_uid”;

 

<?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= "SELECT logcode FROM my_users WHERE id='$cookie_uid'";
$result=mysql_query($res);
// no die() this time, we will redirect if error occurs
if ($result) {
// now see if user’s id exists in database
   if (mysql_num_rows($result,0)) {
  $logcode_in_base= mysql_result($result, 0);
  // now compare LOGCODES in cookie against the one in database
  if ($logcode_in_base == $cookie_code) {
   //function to generate string
function func_generate_string() {
$auto_string= chr(mt_rand(ord('A'), ord('Z')));
for ($i= 0; $i<8; $i++) {
$ltr= mt_rand(1, 3);
if ($ltr==1) $auto_password .= chr(mt_rand(ord('A'), ord('Z')));
if ($ltr==2) $auto_password .= chr(mt_rand(ord('a'), ord('z')));
if ($ltr==3) $auto_password .= chr(mt_rand(ord('0'), ord('9')));
}
return $auto_string;
}
    // if valid, generate new logcode and update database
$newcode= md5(func_generate_string());
$res=“UPDATE my_users SET logcode='$newcode' WHERE id=$cookie_uid”;
     $result=mysql_query($res);
   // setup new cookie (replace the old one)
   $newval= “$cookie_uid:$newcode”;
   setcookie("cookiename", $newval, time() + 300, "/", ".brunelvoxbox.dyndns.org");
   // finally, setup global var to reflect user’s id
   $global_user_id= '$cookie_uid';
  } else {
   // redirect if logcodes are not equal
  }
} else {
  // redirect if user ID does not exist in database
}
} else {
  // redirect in case of database error
}
} else {
// redirect if user ID in cookie not numeric
}
}
?>

 

The problems are here,

 

$res=“UPDATE my_users SET logcode='$newcode' WHERE id=$cookie_uid”;
     $result=mysql_query($res);
   // setup new cookie (replace the old one)
   $newval= “$cookie_uid:$newcode”;

 

You are not using double quotes but a weird variation.

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.