Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fatal error: Cannot redeclare mss() (previously declared in *

Tags:

function

php

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

like image 367
Rob Avatar asked Aug 09 '10 01:08

Rob


2 Answers

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.

like image 141
Ben Rowe Avatar answered Sep 21 '22 02:09

Ben Rowe


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.

like image 33
Mike B Avatar answered Sep 24 '22 02:09

Mike B