4

After I have instaled in my site one script, I have an error:

Fatal error: Cannot redeclare ae_detect_ie() (previously declared in /home/xdesign/public_html/Powerful/config.php:24) in /home/xdesign/public_html/Powerful/config.php on line 29

This is the line:

function ae_detect_ie()
{
    if (isset($_SERVER['HTTP_USER_AGENT']) && 
    (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false))
        return true;
    else
        return false;
}

I don't understand what I did wrong!

The site: http://fbswapes.com

The same script is working in another host.

Cindy SeoLine
  • 51
  • 1
  • 1
  • 3
  • Check [this](http://stackoverflow.com/questions/3620659/is-it-possible-to-overwrite-a-function-in-php) & [this](http://stackoverflow.com/questions/1837184/is-it-possible-to-replace-a-function-in-php-such-as-mail-and-make-it-do-someth) out. – BlitZ May 08 '13 at 02:24
  • 1
    Wrap it with `! function_exists()` as a quick and dirty hack? – alex May 08 '13 at 02:27
  • 4
    Or use `include_once()` to prevent loading your config file twice. – mario May 08 '13 at 02:28
  • This give me error.. Parse error: syntax error, unexpected T_FUNCTION in /home/xdesign/public_html/Powerful/config.php on line 22 – Cindy SeoLine May 08 '13 at 02:32
  • This generally happens when you try to define an already defined function. Use **include_once**. – Airy Jan 25 '14 at 08:17

1 Answers1

8

Simpily you have declared a function twice.. Example:

Global.Fun.php

<?php

      function Do_Something (){
       echo "This Does Something";
      }
?>

Index.php

<?php
   include "Global.Fun.php";
   function Do_Something($Arg){
    echo "Argument Supplied".$Arg;
   }
?>

Notice, I have declared the same function twice, one in my global.fun.php page and again in the index.php page..

If you are in doubt that a function is currently set:

if (function_exists('Do_Something')){
   echo "Function Exists"; 
}else{
   echo "Function Not Found, This name Can be used!";
}
Daryl Gill
  • 5,464
  • 9
  • 36
  • 69
  • Done new si working, but i have this error: Warning: mysql_fetch_array() [function.mysql-fetch-array]: The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH. in /home/xdesign/public_html/Powerful/header.php on line 885 In the line 885 , I have: 885 while ($row = mysql_fetch_array($result, $numass)) { 886 array_push($got, $row); 887 } – Cindy SeoLine May 08 '13 at 02:43
  • @CindySeoLine The error being..? – Daryl Gill May 08 '13 at 02:43
  • Warning: mysql_fetch_array() [function.mysql-fetch-array]: The result type should be either MYSQL_NUM, MYSQL_ASSOC or MYSQL_BOTH. in /home/xdesign/public_html/Powerful/header.php on line 885 In the line 885 – Cindy SeoLine May 08 '13 at 02:53
  • @CindySeoLine Please post the code to your question. – Daryl Gill May 08 '13 at 03:03
  • while ($row = mysql_fetch_array($result, $numass)) { – Cindy SeoLine May 08 '13 at 03:15
  • @CindySeoLine As you have already asked another question with this error message I will not reply here. Furthermore, if this has resolved your initial problem with the function redeclaration issue. Then mark this as the answer by clicking the green tick underneath the votes – Daryl Gill May 08 '13 at 03:27