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 Link to comment https://forums.phpfreaks.com/topic/83957-ereg-error-function-name-must-be-a-string/ 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? Link to comment https://forums.phpfreaks.com/topic/83957-ereg-error-function-name-must-be-a-string/#findComment-427239 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 Link to comment https://forums.phpfreaks.com/topic/83957-ereg-error-function-name-must-be-a-string/#findComment-427257 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. Link to comment https://forums.phpfreaks.com/topic/83957-ereg-error-function-name-must-be-a-string/#findComment-427269 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.