Page 1 of 2

PHP error i cannot figure out... [Archive] - ForumsHQ

Posted: Fri Jan 10, 2003 3:55 pm
by Durin
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..:)

Re: PHP error i cannot figure out... [Archive] - ForumsHQ

Posted: Fri Jan 10, 2003 4:04 pm
by Speed
I don't know much at PHP, but I know C++. This is line 9:

user_id int DEFAULT '0' NOT NULL AUTO_INCREMENT,



There's probably something wrong with that line. I don't know what though, cause the DEFAULT '0' NOT NULL AUTO_INCREMENT is gibberish to me.

Re: PHP error i cannot figure out... [Archive] - ForumsHQ

Posted: Fri Jan 10, 2003 4:06 pm
by Durin
heh nod, i dunno whats wrong with it. It SHOULD work i do believe. That line makes a variable 'user_id' default of '0' and says it cannot be null. Then AUTO_INCREMENT adds up as u add more users. IT SHOULD WORK!! :D

Re: PHP error i cannot figure out... [Archive] - ForumsHQ

Posted: Fri Jan 10, 2003 4:18 pm
by War Hawk
try using ` ` not ' ' where the 0 is the ` are on the tilde key

Re: PHP error i cannot figure out... [Archive] - ForumsHQ

Posted: Fri Jan 10, 2003 4:19 pm
by Durin
Do i have to make the create table in a separate .php file?

Re: PHP error i cannot figure out... [Archive] - ForumsHQ

Posted: Fri Jan 10, 2003 4:25 pm
by Durin
heh i have undefined errors now. $PHP_SELF should be defined as what to start?

Re: PHP error i cannot figure out... [Archive] - ForumsHQ

Posted: Fri Jan 10, 2003 4:25 pm
by Durin
'.$feedback.'';

}



echo 'Login To PHPBuilder



Enter your user name and password and we\'ll set a cookie so we know you\'re logged in.





User Name:





Password:











[ Register A New Account ]



[ Change Your Password ]



[ Change Your Email Address ]';



site_footer();



?>





is the code of the login.php where i have the undefineds...

Re: PHP error i cannot figure out... [Archive] - ForumsHQ

Posted: Fri Jan 10, 2003 5:15 pm
by Durin
".@mysql_error()."\n\n";

}



//connect to the db

//I usually call from pre.php

db_connect();



?>





This is only so i can see it better ;) If i open in notepad its all screwed up. Plus i still boggeled. heh.

Re: PHP error i cannot figure out... [Archive] - ForumsHQ

Posted: Fri Jan 10, 2003 5:17 pm
by Speed
You should also post the exact error message. This would help with debugging, as it gives line #'s and the exact error. If you post the error message, even people w/o PHP experience can be of help (Like myself).

Re: PHP error i cannot figure out... [Archive] - ForumsHQ

Posted: Fri Jan 10, 2003 5:22 pm
by Durin
ok, very good point ;) This is the erros i get when i load up login.php.



Parse error: parse error, unexpected T_STRING in d:\xitami\webpages\include\database.php on line 13



Parse error: parse error, unexpected T_STRING in d:\xitami\webpages\include\user.php on line 9



Parse error: parse error, unexpected T_STRING in d:\xitami\webpages\include\database.php on line 13



Fatal error: Call to undefined function: user_isloggedin() in D:\Xitami\webpages\login.php on line 11





database.php:



".@mysql_error()."\n\n";

}



//connect to the db

//I usually call from pre.php

db_connect();



?>



user.php



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));

}



?>







Thats alot i know ;) And i VERY VERY much appreciate the help with any of this. :) Any other things just let me know