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

I do not understand, the function does not exist, and even if I change it to some absurd names, it still does not work. Can anyone find a problem?

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

EDIT: I forgot to mention its XAMPP

+6
function php
source share
5 answers

This will mean that you either defined the function at two separate points or included the same file twice.

Use include_once / require_once instead of include / require.

+7
source share

Ben Rowe's answer is almost certainly the reason why this happens.

I do not 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 decision is erratic. It is almost always preferable to find out WHY your file is included twice or where this function is defined twice. But for special circumstances, this decision may be appropriate.

+3
source share

If you save it in a separate file, do you include it several times by accident?

+1
source share

include_once (does not include) works as long as the function is declared once only in a separate .php file. Please double check that the function is not mentioned elsewhere.

0
source share

You should: include_once instead of: include

0
source share

All Articles