Jump to content


Photo

??? Fatal error: Cannot redeclare showerror() previously declared


  • Please log in to reply
11 replies to this topic

#1 drranch

drranch
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 19 July 2006 - 04:56 PM

??? Need help with the following error message  ???
Fatal error: Cannot redeclare showerror() (previously declared in D:\inetpub\vhosts\etest.com\httpdocs\connect\db.inc:12) in D:\inetpub\vhosts\etest.com\httpdocs\connect\db.inc on line 10

The above message is confusing me, ... This message is pointing to a function I created :-\ here is the code

1<?php
2
3
4  $hostName = "localhost";
5  $databaseName = "etest";
6  $username = "sam";
7  $password = "shhh";
8
9
10    function showerror()
11  {
12  die("Error " . mysql_errno() . " : " . mysql_error());
13  }
14
15  function mysqlclean($array, $index, $maxlength, $connection)
16  {
17    if (isset($array["{$index}"]))
18    {
19        $input = substr($array["{$index}"], 0, $maxlength);
20        $input = mysql_real_escape_string($input, $connection);
21        return ($input);
22    }
23    return NULL;
24  }
25
26  function shellclean($array, $index, $maxlength)
27  {
28    if (isset($array["{$index}"]))
29    {
30      $input = substr($array["{$index}"], 0, $maxlength);
31      $input = EscapeShellArg($input);
32      return ($input);
33    }
34    return NULL;
35  }
36?>






#2 Joe Haley

Joe Haley
  • Members
  • PipPipPip
  • Advanced Member
  • 103 posts
  • LocationCanada, eh?

Posted 19 July 2006 - 05:09 PM

have you declared the function showerror on any of the script files that include this?
Give a man a fish; you have fed him for today.  Teach a man to fish; and you have fed him for a lifetime
Don't teach men to program. Teach them to fish.

Please, try the RTFM solution before asking for help:
http://php.net/manual/en/index.php

#3 drranch

drranch
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 19 July 2006 - 05:22 PM

No, all three files do not have showerror on them in any way shape or form (declared or not declared) ???

#4 Joe Haley

Joe Haley
  • Members
  • PipPipPip
  • Advanced Member
  • 103 posts
  • LocationCanada, eh?

Posted 19 July 2006 - 05:32 PM

tryd renaming the function?
Give a man a fish; you have fed him for today.  Teach a man to fish; and you have fed him for a lifetime
Don't teach men to program. Teach them to fish.

Please, try the RTFM solution before asking for help:
http://php.net/manual/en/index.php

#5 drranch

drranch
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 19 July 2006 - 07:44 PM

::)  Oh man I've renamed the function only to receive the same message.  I renamed the file and received the same message :'( I removed the function from the file and ran the script again and this is the message received....

Fatal error: Cannot redeclare mysqlclean() (previously declared in D:\inetpub\vhosts\etest.com\httpdocs\connect\test.php:10) in D:\inetpub\vhosts\etest.com\httpdocs\connect\test.php on line 10

I'm thinking there is something on my HOST provider's server (like cache????) that may be causing these messages. I could be crazy though :o

I checked mysqlclean and nothing else in any of the included files have been declared as mysqlclean.... :-\


#6 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 19 July 2006 - 07:49 PM

try running this at the top of your file:

exit('<pre>'.print_r(get_defined_functions(), TRUE));

see if your functions already exist in the scope somehow.  if not, it's probably a host issue.

#7 drranch

drranch
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 19 July 2006 - 08:14 PM

Yeah ...
I ran the code like you suggested and I did get a lot of functions, but this looks most interesting.......

[user] => Array
        (
            [0] => authenticateuser
            [1] => registerlogin
            [2] => unregisterlogin
            [3] => sessionauthenticate
            [4] => showerror
            [5] => mysqlclean
            [6] => shellclean
        )
Ok its time for me to get educated...What is driving this list???

#8 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 19 July 2006 - 08:22 PM

that list is grabbed by get_defined_functions(), which grabs all currently defined functions in the PHP script.  not too sure what to tell you, if you put that line at the top of your php file.  are you including any other scripts before calling the exit() line?

those are all the custom functions defined by the user at that point of script execution.  if you're not including anything in that file itself, it could be an auto-appendage?  what code is on the file that spits out that list?

#9 drranch

drranch
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 19 July 2006 - 08:31 PM

I put the script you provided on line three of the script I orginally posted.......

Yeah all of those are related to different pages on my site, but it still doesn't get me any closer to why the already defined error message is showing. 

I checked and rechecked for already defined items and theres nothing. :o But then again I may be crazy and not the gods.....

So I sent an email to my HOST support tech...mmmm...waiting....waiting...waiting......we will see if that gets me any where. 

In the mean time I will search all files on my site to see if I can find an already defined item.




#10 akitchin

akitchin
  • Staff Alumni
  • Advanced Member
  • 2,516 posts
  • LocationCalgary, AB, Canada

Posted 19 July 2006 - 08:43 PM

try running:

<?php
phpinfo();
?>

and also:

<?php
echo ini_get('auto_prepend_file');
?>

and see if anything returns.  the only way i can think of these being defined before you yourself include anything (or define anything) is if a file is automatically prepended to all scripts.

#11 drranch

drranch
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 19 July 2006 - 09:02 PM

nothing was returned and everything looks good in the phpinfo file....

OBTW - thanks for the education on the defined functions listing ...I reviewed and reviewed it and its making sense... ;D but I haven't found where they have been defined....

It will have to wait for now.  Your one smart cookie.  Thanks for your help!  I'll follow up with resolution once I can get back at it.





#12 drranch

drranch
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 20 July 2006 - 05:48 AM

:o

Welp I figured it out.  I was calling my database on the page that opens after I authenticate the logged in user.  I should have had only the authentication.inc file at the top of this page and session_start() and my defined function of sessionAuthenticate().  Wam Bam thank you mam!

I learned a lot and my new motto is...

There is no failure, only feed back....

Thanks again Joe Haily and akitchin for holding my hand as I walk through my darkness of PHP ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users