phpdonut Posted April 2, 2008 Share Posted April 2, 2008 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 } } ?> Link to comment https://forums.phpfreaks.com/topic/99210-parse-error-syntax-error-unexpected-t_string/ Share on other sites More sharing options...
Cep Posted April 2, 2008 Share Posted April 2, 2008 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. Link to comment https://forums.phpfreaks.com/topic/99210-parse-error-syntax-error-unexpected-t_string/#findComment-507612 Share on other sites More sharing options...
phpdonut Posted April 2, 2008 Author Share Posted April 2, 2008 so what would i change that to?? Link to comment https://forums.phpfreaks.com/topic/99210-parse-error-syntax-error-unexpected-t_string/#findComment-507614 Share on other sites More sharing options...
Cep Posted April 2, 2008 Share Posted April 2, 2008 Well just replace these “ with these " Link to comment https://forums.phpfreaks.com/topic/99210-parse-error-syntax-error-unexpected-t_string/#findComment-507617 Share on other sites More sharing options...
phpdonut Posted April 2, 2008 Author Share Posted April 2, 2008 thank you that worked, wasn't sure what you meant the first time, not sure how those weird quotes got in there!!! Link to comment https://forums.phpfreaks.com/topic/99210-parse-error-syntax-error-unexpected-t_string/#findComment-507620 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.