Jump to content

ereg() - error: function name must be a string


PC Nerd

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.