Jump to content
Larry Ullman's Book Forums

Recommended Posts

I also want to echo the applause for this book. I can find bits and pieces on the web; the php manual is great BUT if you are new to the topic (like me) and have no context, no understanding why to do these things this way and how to put them all together, it is a very painful trial and error. So thanks, Larry!

 

I have set up my error_handler in config.inc.php. It is working fine except with my login script (Chap. 12). I am using login_functions.inc.php (Script 12.2) and the errors are not printing to the screen. Instead I get this error message.

 

Fatal error: Cannot redeclare my_error_handler() (previously declared in C:\wamp\www....\includes\config.inc.php:45) in C:\wamp\www\...\includes\config.inc.php on line 75

 

The function check_login() is being used. I do get content into errors array. I did do a var_dump of the errors array and did check that. But I don't know why it is causing the error. I don't see where I have redeclared my_error_handler().

 

Thank you for any help you may give.

N.

Link to comment
Share on other sites

Require the config.inc.php file at the top of the script.

 

require ('./includes/config.inc.php'); There is also a require_once php function you can use, so if you do have require somewhere else then it won't load that php script again.

Link to comment
Share on other sites

Solved. Thanks for the suggestion!

 

On login_page.inc.php, I changed my code to :

 

include_once ('../includes/config.inc.php');

require_once (MYSQL);

 

There was a side effect of this code change in my site. My login page has a limited number of users and so I have a select box of user's names which is queried from the database. If someone puts in the wrong password, Larry's original script shows the error and then below it the form again. Well, my form displayed but the select box collapsed because it needed a MySQL connection but can no longer get it because of the "require_once." So I replaced the display of the form with a link "back" to the original page.

 

I mention this for any other newbies out there.

Link to comment
Share on other sites

Yes that's all well but there is still an extra call for include_once ('../includes/config.inc.php') on line 75 according to your error handler, even if you are using include_once you only need to make a call to include or require the config.inc.php one time. Therefore you need to check line 75 of your script to remove that extra line out.

Link to comment
Share on other sites

 Share

×
×
  • Create New...