PHP error i cannot figure out... [Archive] - ForumsHQ
Posted: Fri Jan 10, 2003 3:55 pm
Parse error: parse error, unexpected T_STRING,
wtf does this mean?? the code looks fine.
0) {
$feedback .= ' ERROR - USER NAME EXISTS ';
return false;
} else {
//create a new hash to insert into the db and the confirmation email
$hash=md5($email.$hidden_hash_var);
$sql="INSERT INTO user (user_name,real_name,password,email,remote_addr,co nfirm_hash,is_confirmed) ".
"VALUES ('$user_name','$real_name','". md5($password1) ."','$email','$GLOBALS[REMOTE_ADDR]','$hash','0')";
$result=db_query($sql);
if (!$result) {
$feedback .= ' ERROR - '.db_error();
return false;
} else {
//send the confirm email
user_send_confirm_email($email,$hash);
$feedback .= ' Successfully Registered. You Should Have a Confirmation Email Waiting ';
return true;
}
}
} else {
$feedback .= ' Account Name or Password Invalid ';
return false;
}
} else {
$feedback .= ' ERROR - Must Fill In User Name, Matching Passwords, And Provide Valid Email Address ';
return false;
}
}
function user_getid() {
global $G_USER_RESULT;
//see if we have already fetched this user from the db, if not, fetch it
if (!$G_USER_RESULT) {
$G_USER_RESULT=db_query("SELECT * FROM user WHERE user_name='" . user_getname() . "'");
}
if ($G_USER_RESULT && db_numrows($G_USER_RESULT) > 0) {
return db_result($G_USER_RESULT,0,'user_id');
} else {
return false;
}
}
function user_getrealname() {
global $G_USER_RESULT;
//see if we have already fetched this user from the db, if not, fetch it
if (!$G_USER_RESULT) {
$G_USER_RESULT=db_query("SELECT * FROM user WHERE user_name='" . user_getname() . "'");
}
if ($G_USER_RESULT && db_numrows($G_USER_RESULT) > 0) {
return db_result($G_USER_RESULT,0,'real_name');
} else {
return false;
}
}
function user_getemail() {
global $G_USER_RESULT;
//see if we have already fetched this user from the db, if not, fetch it
if (!$G_USER_RESULT) {
$G_USER_RESULT=db_query("SELECT * FROM user WHERE user_name='" . user_getname() . "'");
}
if ($G_USER_RESULT && db_numrows($G_USER_RESULT) > 0) {
return db_result($G_USER_RESULT,0,'email');
} else {
return false;
}
}
function user_getname() {
if (user_isloggedin()) {
return $GLOBALS['user_name'];
} else {
//look up the user some day when we need it
return ' ERROR - Not Logged In ';
}
}
function account_pwvalid($pw) {
global $feedback;
if (strlen($pw) 0) {
$feedback .= " There cannot be any spaces in the login name. ";
return false;
}
// must have at least one character
if (strspn($name,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX YZ") == 0) {
$feedback .= "There must be at least one character.";
return false;
}
// must contain all legal characters
if (strspn($name,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX YZ0123456789-_")
!= strlen($name)) {
$feedback .= " Illegal character in name. ";
return false;
}
// min and max length
if (strlen($name) 15) {
$feedback .= "Name is too long. It must be less than 15 characters.";
return false;
}
// illegal names
if (eregi("^((root)|(bin)|(daemon)|(adm)|(lp)|(sync)|(shutdow n)|(halt)|(mail)|(news)"
. "|(uucp)|(operator)|(games)|(mysql)|(httpd)|(nobody )|(dummy)"
. "|(www)|(cvs)|(shell)|(ftp)|(irc)|(debian)|(ns)|(do wnload))$",$name)) {
$feedback .= "Name is reserved.";
return 0;
}
if (eregi("^(anoncvs_)",$name)) {
$feedback .= "Name is reserved for CVS.";
return false;
}
return true;
}
function validate_email ($address) {
return (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'. '@'. '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $address));
}
?>
this is code from a pre made user login package. I dont know enough to write my own so i figured id use this one ;) And learn from it but i cannot seem to figure it out. The directions said to create a table 'user' at the top of this file and i did that. But it doesnt work, any help would be nice ;) {I needs CLEAR direction as i am very stupid on this matter ;)} Thanks again guys.
::The site i got this package from is this one
http://www.phpbuilder.com/columns/tim20000505.php3?page=3
Once again, THANKS!! :D
EDIT:: Parse error: parse error, unexpected T_STRING in D:\Xitami\webpages\include\user.php on line 9
thats the exact error when i try to access it..:)
wtf does this mean?? the code looks fine.
0) {
$feedback .= ' ERROR - USER NAME EXISTS ';
return false;
} else {
//create a new hash to insert into the db and the confirmation email
$hash=md5($email.$hidden_hash_var);
$sql="INSERT INTO user (user_name,real_name,password,email,remote_addr,co nfirm_hash,is_confirmed) ".
"VALUES ('$user_name','$real_name','". md5($password1) ."','$email','$GLOBALS[REMOTE_ADDR]','$hash','0')";
$result=db_query($sql);
if (!$result) {
$feedback .= ' ERROR - '.db_error();
return false;
} else {
//send the confirm email
user_send_confirm_email($email,$hash);
$feedback .= ' Successfully Registered. You Should Have a Confirmation Email Waiting ';
return true;
}
}
} else {
$feedback .= ' Account Name or Password Invalid ';
return false;
}
} else {
$feedback .= ' ERROR - Must Fill In User Name, Matching Passwords, And Provide Valid Email Address ';
return false;
}
}
function user_getid() {
global $G_USER_RESULT;
//see if we have already fetched this user from the db, if not, fetch it
if (!$G_USER_RESULT) {
$G_USER_RESULT=db_query("SELECT * FROM user WHERE user_name='" . user_getname() . "'");
}
if ($G_USER_RESULT && db_numrows($G_USER_RESULT) > 0) {
return db_result($G_USER_RESULT,0,'user_id');
} else {
return false;
}
}
function user_getrealname() {
global $G_USER_RESULT;
//see if we have already fetched this user from the db, if not, fetch it
if (!$G_USER_RESULT) {
$G_USER_RESULT=db_query("SELECT * FROM user WHERE user_name='" . user_getname() . "'");
}
if ($G_USER_RESULT && db_numrows($G_USER_RESULT) > 0) {
return db_result($G_USER_RESULT,0,'real_name');
} else {
return false;
}
}
function user_getemail() {
global $G_USER_RESULT;
//see if we have already fetched this user from the db, if not, fetch it
if (!$G_USER_RESULT) {
$G_USER_RESULT=db_query("SELECT * FROM user WHERE user_name='" . user_getname() . "'");
}
if ($G_USER_RESULT && db_numrows($G_USER_RESULT) > 0) {
return db_result($G_USER_RESULT,0,'email');
} else {
return false;
}
}
function user_getname() {
if (user_isloggedin()) {
return $GLOBALS['user_name'];
} else {
//look up the user some day when we need it
return ' ERROR - Not Logged In ';
}
}
function account_pwvalid($pw) {
global $feedback;
if (strlen($pw) 0) {
$feedback .= " There cannot be any spaces in the login name. ";
return false;
}
// must have at least one character
if (strspn($name,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX YZ") == 0) {
$feedback .= "There must be at least one character.";
return false;
}
// must contain all legal characters
if (strspn($name,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX YZ0123456789-_")
!= strlen($name)) {
$feedback .= " Illegal character in name. ";
return false;
}
// min and max length
if (strlen($name) 15) {
$feedback .= "Name is too long. It must be less than 15 characters.";
return false;
}
// illegal names
if (eregi("^((root)|(bin)|(daemon)|(adm)|(lp)|(sync)|(shutdow n)|(halt)|(mail)|(news)"
. "|(uucp)|(operator)|(games)|(mysql)|(httpd)|(nobody )|(dummy)"
. "|(www)|(cvs)|(shell)|(ftp)|(irc)|(debian)|(ns)|(do wnload))$",$name)) {
$feedback .= "Name is reserved.";
return 0;
}
if (eregi("^(anoncvs_)",$name)) {
$feedback .= "Name is reserved for CVS.";
return false;
}
return true;
}
function validate_email ($address) {
return (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'. '@'. '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $address));
}
?>
this is code from a pre made user login package. I dont know enough to write my own so i figured id use this one ;) And learn from it but i cannot seem to figure it out. The directions said to create a table 'user' at the top of this file and i did that. But it doesnt work, any help would be nice ;) {I needs CLEAR direction as i am very stupid on this matter ;)} Thanks again guys.
::The site i got this package from is this one
http://www.phpbuilder.com/columns/tim20000505.php3?page=3
Once again, THANKS!! :D
EDIT:: Parse error: parse error, unexpected T_STRING in D:\Xitami\webpages\include\user.php on line 9
thats the exact error when i try to access it..:)