1

I think I have had a bug with a contact form which has been working for the last 2 months and now all of a sudden is says:

Fatal error: Cannot redeclare function (previously declared in...)

I have tried turning off the functions one by one but it just gives same error for next function down. My code is pretty standard. but, here it is (this is the beginning of the function. The code is long) //Functions

  function e($value)
  {
     return htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
  }

  //---------die dump function----------
  function dd($data)
  {
      die(var_dump($data));
  }

   //Booking Page code (beginning)
   <?php
   require 'includes/config.php';

   $name = $email = $date = $phone = $age = $tour = $message = '';
   $errors = [];


  if ($_SERVER["REQUEST_METHOD"] == "POST") {


  $name = e($_POST['name']);
  $email = e($_POST['email']);
  $tour = !empty($_POST['tour']) ? $_POST['tour'] : '';
  $phone = e($_POST['phone']);
  $date = e($_POST['date']);
  $age = e($_POST['age']);
  $message = e($_POST['message']);

  $errors['name'] = checkNameBooking($name);
  $errors['email'] = checkEmailBooking($email);
  $errors['tour'] = checkTourBooking($tour);
  $errors['date'] = checktimeBooking($date);
  $errors['age'] = checkAgeBooking($age);
sanders
  • 10,794
  • 27
  • 85
  • 127
Simone
  • 21
  • 1
  • 4
    You're probably using `require` or `include` on the same file twice somewhere. Try changing them all to `require_once` and `include_once`, and test again – Mads Marquart Sep 27 '17 at 19:41
  • Hi thanks for your help, I tried that and then the code just runs for ages and gives me the following error Allowed memory size of 134217728 bytes exhausted (tried to allocate 8192 bytes) in /Applications.....I have looked thought and I am only including the functions once also its been working find for the past 2 months, very weird? Any other ideas? – Simone Sep 28 '17 at 02:50

0 Answers0