andrew wong Posted September 16, 2021 Share Posted September 16, 2021 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 More sharing options...
andrew wong Posted September 16, 2021 Author Share Posted September 16, 2021 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 More sharing options...
andrew wong Posted September 16, 2021 Author Share Posted September 16, 2021 but i find that the user record can be inserted into the database Link to comment Share on other sites More sharing options...
Larry Posted September 17, 2021 Share Posted September 17, 2021 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 More sharing options...
andrew wong Posted September 18, 2021 Author Share Posted September 18, 2021 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:14Warning: 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 More sharing options...
Larry Posted September 19, 2021 Share Posted September 19, 2021 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 More sharing options...
andrew wong Posted September 20, 2021 Author Share Posted September 20, 2021 Thanks larry since i do not have local mail server, can i use php.net mail server ? [mail function] ; For Win32 only. ; http://php.net/smtp SMTP=localhost ; http://php.net/smtp-port smtp_port=25 Link to comment Share on other sites More sharing options...
andrew wong Posted September 20, 2021 Author Share Posted September 20, 2021 Hi Larry, can you give me some advise how to install a local mail server ? I am using XAMPP Thanks Link to comment Share on other sites More sharing options...
Larry Posted September 20, 2021 Share Posted September 20, 2021 If you just google "xampp mail server windows" you'll find plenty of tutorials on the subject. (I don't have XAMPP on Windows, so I don't know off the top of my head.) Link to comment Share on other sites More sharing options...
andrew wong Posted September 21, 2021 Author Share Posted September 21, 2021 ok, thanks larry i will try to figure out myself Link to comment Share on other sites More sharing options...
Recommended Posts