PC Nerd Posted January 1, 2008 Share Posted January 1, 2008 Hi, Im working on a validation script for creating user accounts - and Im not at all familiar with ereg(), preg_match() etc. Ive been mashing together expressions from forums etc - and Ive come accrose the error with the following line: if(!ereg("[A-za-z' -]{1, 50}", $trim($value))) { Here is the surounding code: ... ... foreach($_POST as $field => $value) { if($_POST['Save'] == 1 && $field == "User_Name" || $field == "Password" || $field == "Conf_Password" || $field == "Email" || $field == "Emg_Relation") { ### Validate the Username, password and email if(!ereg("[A-za-z' -]{1, 50}", $trim($value))) { $ERROR[$idx]['err'] = "invalid"; $ERROR[$idx]['empty'] = $field; $idx ++; } if(strlen($value) > 20) { ... ... The error is this: Fatal error: Function name must be a string in ###\new_user.php on line 60 Im confused by the meaning of this error - meaning ihave no clue as how to fix it. Any suggestions or answers woudl be much appreciated. Thanks in advance Quote Link to comment Share on other sites More sharing options...
JJohnsenDK Posted January 1, 2008 Share Posted January 1, 2008 do you get the same error with preg_match()? And of what type is $value? String? Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted January 1, 2008 Share Posted January 1, 2008 A function cannot have a $ in front of the name. <?php $trim($value) needs to be <?php trim($value) PhREEEk Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted January 1, 2008 Share Posted January 1, 2008 A function cannot have a $ in front of the name. <?php $trim($value) needs to be <?php trim($value) PhREEEk It can, but only if the variable contains the name of a valid function. E.g. $func = 'print'; $arg = 'test'; $func($arg); will output test. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.