Jump to content
Larry Ullman's Book Forums

when i tried to run the user registration example program, I got some error. please help


Recommended Posts

http://127.0.0.1/phpmysql4_scripts/ch18/html/register.php

 

User Registration

Fatal error: Uncaught ArgumentCountError: Too few arguments to function my_error_handler(), 4 passed and exactly 5 expected in D:\xampp\htdocs\phpmysql4_scripts\ch18\html\includes\config.inc.php:38 Stack trace: #0 D:\xampp\htdocs\phpmysql4_scripts\ch18\html\register.php(10): my_error_handler(2, 'require(../../m...', 'D:\\xampp\\htdocs...', 10) #1 D:\xampp\htdocs\phpmysql4_scripts\ch18\html\register.php(10): require() #2 {main} thrown in D:\xampp\htdocs\phpmysql4_scripts\ch18\html\includes\config.inc.php on line 38
Link to comment
Share on other sites

User Registration

Fatal error: Uncaught ArgumentCountError: Too few arguments to function my_error_handler(), 4 passed and exactly 5 expected in D:\xampp\htdocs\phpmysql4_scripts\ch18\html\includes\config.inc.php:38 Stack trace: #0 [internal function]: my_error_handler(2, 'mail(): Failed ...', 'D:\\xampp\\htdocs...', 70) #1 D:\xampp\htdocs\phpmysql4_scripts\ch18\html\register.php(70): mail('trandrew8@gmail...', 'Registration Co...', 'Thank you for r...', 'From: admin@sit...') #2 {main} thrown in D:\xampp\htdocs\phpmysql4_scripts\ch18\html\includes\config.inc.php on line 38
Link to comment
Share on other sites

There are two issues here. One is that there's an error going on in the script. The second is the error handling isn't working properly. For the latter, you don't mention what version of PHP you're using, but I expect the warning in the box applies: https://www.php.net/manual/en/function.set-error-handler.php

Remove the last parameter from the my_error_handler() definition, as well as the use of that $e_vars variable within it. 

Once you fix that, you should properly see the actual error that's happening on the page.

Link to comment
Share on other sites

Hi Larry,

Thanks for your responding.

I have removed the last parameter from my_error_handler()

 

when i run again http://127.0.0.1/phpmysql4_scripts/ch18/html/register.php

 

User Registration
An error occurred in script 'D:\xampp\htdocs\phpmysql4_scripts\ch18\html\register.php' on line 70: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
Date/Time: 9-17-2021 23:23:14

Warning: Undefined variable $e_vars in D:\xampp\htdocs\phpmysql4_scripts\ch18\html\includes\config.inc.php on line 54
#0  my_error_handler(2, mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set(), D:\xampp\htdocs\phpmysql4_scripts\ch18\html\register.php, 70)
#1  mail(wongkinping@chinalifeagt.com.hk, Registration Confirmation, Thank you for registering at . To activate your account, please click on this link:

http://127.0.0.1/phpmysql4_scripts/ch18/html/activate.php?x=wongkinping%40chinalifeagt.com.hk&y=a331f2faab5825188d23eca77974f18f, From: admin@sitename.com) called at [D:\xampp\htdocs\phpmysql4_scripts\ch18\html\register.php:70]

Thank you for registering! A confirmation email has been sent to your address. Please click on the link in that email in order to activate your account.

 

 

sorry for any simple question, but I am new to PHP.

Thanks

Andrew

Link to comment
Share on other sites

From there error messages, you have two issues to resolve. The first is you haven't configured a local mail server. The second is your error handling script still references the $e_vars variable, which it no longer has defined as an argument. 

Link to comment
Share on other sites

 Share

×
×
  • Create New...