So my problem is that PHP says I am trying to redeclare a function when I am just trying to use it.

Here is my code

include("openclosedb.php");
       include("mysqlbuilder.php");
       include("utilityfunctions.php");
       if($_POST['submit'])
       {
           $cust = new Customer($_POST["western_id"], $_POST["name"], $_POST["address"], $_POST["phone"], $_POST["email"]);
           $que = buildInsert($cust->table_name, $cust->data);
           mysql_query($que);
       }

In my file "mysqlbuilder.php" lies a function called buildInsert, which takes 2 values. When the page is submitted to itself I want to build and insert statement and then run it on my DB. Problem is whenever I run the statement I get a fatal error saying I am trying to redeclare my the function buildInsert when I am just trying to use it. Any suggestions?

    My guess is that you include the same file twice, or that you have the function definition in two different places. If you showed us a copy of the actual error message, it might make things clearer.

    Anyway, when including a file whose only purpose is to define some functions and/or classes, it's generally a good idea to using require_once or include_once rather than require or include, specifically to avoid such multiple definition attempts.

      NogDog wrote:

      My guess is that you include the same file twice, or that you have the function definition in two different places. If you showed us a copy of the actual error message, it might make things clearer.

      Anyway, when including a file whose only purpose is to define some functions and/or classes, it's generally a good idea to using require_once or include_once rather than require or include, specifically to avoid such multiple definition attempts.

      Oh thanks... ummm... what is the difference between include and require? Require is not mentioned in the book I am using

        Read the PHP Manual on [man]include[/man] and [man]require[/man].

          Write a Reply...