Jump to content

question about a function error

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Sakizen

Sakizen

    Newbie

  • Members
  • Pip
  • 4 posts
Hey, error that I can't seem to wrap my head around... it doesn't make sense for me.

I am running PHP 5 and when this is the error it prints:


Fatal error: Cannot redeclare sanitizeinput() (previously declared in (dir...)\includes\functions.php:3) in (dir...)\includes\functions.php on line 77
My function, sanitizeInput($string) takes a string, and returns a string variable.

What I don't understand is that it says on line 77(which is just simply an ending bracket to close the function).
Another thing that doesn't make sense, is that it says "Cannot redeclare sanitizeinput()" with empty parameters when my function suppose to accept 1 parameter.

That is all that information that I can think of right now that is relevant, if you should know anymore, please just ask.

Appreciate any help :)

-----------------------------------------------------------------------------------

I actually found out my problem... Here is the solution if anyone else was having the same issue.

This error occured for me because I had my functions.php file being included multiple times, causing the script to run into a redeclare error.

Edited by Sakizen, 17 February 2010 - 04:00 PM.
Found the solution


#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
A good thing to avoid that, is to use include_once() instead of include(). include_once() will check if the file is included already, and if it is, it just does nothing.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
Sakizen

Sakizen

    Newbie

  • Members
  • Pip
  • 4 posts

Orjan said:

A good thing to avoid that, is to use include_once() instead of include(). include_once() will check if the file is included already, and if it is, it just does nothing.

thanks for the tip.