tags:

views:

43

answers:

3

I don't understand, the function doesn't exist, and even if I change it to some absurd names, it still doesn't work. Can anyone find the problem?

function mss($value){
    $data = mysql_real_escape_string(trim(strip_tags($value)));
    return $data;
}

EDIT: I forgot to mention, its XAMPP

A: 

If you're keeping it in a separate file, are you including it more than once accidentally?

Patrick
I just checked, no
Rob
+2  A: 

That will mean that you've either defined the function in two separate spots, or your including the same file twice.

Use include_once/require_once instead of include/require.

Ben Rowe
tried that. same problem
Rob
@Rob just before you declare mss(), use this: var_dump(get_included_files()); Make sure there's no duplicate files being included.
Ben Rowe
+1  A: 

Ben Rowe's answer is almost assuredly the reason why it's happening.

I don't recommend this but you can always wrap your function in function_exists()

if(!function_exists("mss")) {

    function mss($value){
        $data = mysql_real_escape_string(trim(strip_tags($value)));
        return $data;
    }

}

This solution is messy. It's almost always more preferable to find out WHY your file is being included twice or where this function is defined twice. But, for special circumstances this solution could be appropriate.

Mike B
@Mike Yeah that can work. I didn't recommend it because it's usually an unnecessary performance hit.
Ben Rowe
even that produces a `cannot redeclare` error :\
Rob
@Rob Are you sure you're editing the right file? What does the exact error message say? What file/line was it originally declared and what file/line is it being redeclared?
Mike B