drranch Posted July 19, 2006 Share Posted July 19, 2006 ??? 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 10The above message is confusing me, ... This message is pointing to a function I created :-\ here is the code1<?php234 $hostName = "localhost";5 $databaseName = "etest";6 $username = "sam";7 $password = "shhh";8 910 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 }2526 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?> Link to comment https://forums.phpfreaks.com/topic/15051-fatal-error-cannot-redeclare-showerror-previously-declared/ Share on other sites More sharing options...
Joe Haley Posted July 19, 2006 Share Posted July 19, 2006 have you declared the function showerror on any of the script files that include this? Link to comment https://forums.phpfreaks.com/topic/15051-fatal-error-cannot-redeclare-showerror-previously-declared/#findComment-60552 Share on other sites More sharing options...
drranch Posted July 19, 2006 Author Share Posted July 19, 2006 No, all three files do not have showerror on them in any way shape or form (declared or not declared) ??? Link to comment https://forums.phpfreaks.com/topic/15051-fatal-error-cannot-redeclare-showerror-previously-declared/#findComment-60556 Share on other sites More sharing options...
Joe Haley Posted July 19, 2006 Share Posted July 19, 2006 tryd renaming the function? Link to comment https://forums.phpfreaks.com/topic/15051-fatal-error-cannot-redeclare-showerror-previously-declared/#findComment-60564 Share on other sites More sharing options...
drranch Posted July 19, 2006 Author Share Posted July 19, 2006 ::) 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 10I'm thinking there is something on my HOST provider's server (like cache????) that may be causing these messages. I could be crazy though :oI checked mysqlclean and nothing else in any of the included files have been declared as mysqlclean.... :-\ Link to comment https://forums.phpfreaks.com/topic/15051-fatal-error-cannot-redeclare-showerror-previously-declared/#findComment-60611 Share on other sites More sharing options...
akitchin Posted July 19, 2006 Share Posted July 19, 2006 try running this at the top of your file:[code]exit('<pre>'.print_r(get_defined_functions(), TRUE));[/code]see if your functions already exist in the scope somehow. if not, it's probably a host issue. Link to comment https://forums.phpfreaks.com/topic/15051-fatal-error-cannot-redeclare-showerror-previously-declared/#findComment-60614 Share on other sites More sharing options...
drranch Posted July 19, 2006 Author Share Posted July 19, 2006 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??? Link to comment https://forums.phpfreaks.com/topic/15051-fatal-error-cannot-redeclare-showerror-previously-declared/#findComment-60626 Share on other sites More sharing options...
akitchin Posted July 19, 2006 Share Posted July 19, 2006 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? Link to comment https://forums.phpfreaks.com/topic/15051-fatal-error-cannot-redeclare-showerror-previously-declared/#findComment-60628 Share on other sites More sharing options...
drranch Posted July 19, 2006 Author Share Posted July 19, 2006 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. Link to comment https://forums.phpfreaks.com/topic/15051-fatal-error-cannot-redeclare-showerror-previously-declared/#findComment-60637 Share on other sites More sharing options...
akitchin Posted July 19, 2006 Share Posted July 19, 2006 try running:[code]<?phpphpinfo();?>[/code]and also:[code]<?phpecho ini_get('auto_prepend_file');?>[/code]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. Link to comment https://forums.phpfreaks.com/topic/15051-fatal-error-cannot-redeclare-showerror-previously-declared/#findComment-60642 Share on other sites More sharing options...
drranch Posted July 19, 2006 Author Share Posted July 19, 2006 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. Link to comment https://forums.phpfreaks.com/topic/15051-fatal-error-cannot-redeclare-showerror-previously-declared/#findComment-60652 Share on other sites More sharing options...
drranch Posted July 20, 2006 Author Share Posted July 20, 2006 :oWelp 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 ;) Link to comment https://forums.phpfreaks.com/topic/15051-fatal-error-cannot-redeclare-showerror-previously-declared/#findComment-60854 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.