Fatal error: Cannot redeclare not_null() (previously declared in /homepages/8/d252567151/htdocs/whos-online/include-whos-online-header.php:922) in /homepages/8/d252567151/htdocs/contact-inc.php on line 358
Since Mike Challis wrote the originals of both scripts, he likely reused some code. In this case, both include-whos-online-header.php and contact-inc.php both have a function named not_null() –
The easy away around that is to rename the not_null() function in contact-inc.php by changing all ‘not_null’ to ‘not_nullX’ in the script… then it should peacefully coexist with your whos-online scripts. You may have to do the same strategy for other functions if they show a fatal error message like that.
PHP doesn’t allow redefinition of a function once declared. It’s why I generally give script-specific names to functions copied from other scripts just to avoid those possible collisions. I’d discontinued use of whos-online on my site quite a while ago, so I’d not seen that error before release of the contact script.
Did you just try the wxcontact.php shipped with the .zip ? That should work fine. It looks like the include() on your current page is trying to include(“wxcontact.php”) not include(“contact-inc.php”). Except for changing the settings area in contact-inc.php (and renaming all the not_null to not_nullX, there shouldn’t be any other changes to that script).
I didn’t look at the script good enough to see that the header, footer, etc were all included and thought I had to use the include_once method into my current script. My bad.
Yes, unlike my other scripts which work standalone first and template aware second, this one was template first, standalone second. That’s why the wxcontact.php page in the distribution just has
<?php
# wxcontact.php for Saratoga templates
/*
Version 2.00 - 07-Apr-2018 rewritten to use Google reCaptcha V2.0 - Ken True - Saratoga-weather.org
*/
$doStandalone = false;
include_once("contact-inc.php");
# end wxcontact.php
?>
since the contact-inc.php has embedded includes for Settings,top,header,menubar and footer at the proper places to produce a template page.
The script uses the built-in mail() function of PHP … theoretically, that should be set up correctly by your hoster so it just works.
Double check the $mailto setting in the contact-inc.php script. That is where the mail is to go to. It may flow into the Junk/Spam folder of the destination mailbox, so check that too.
No other settings should be needed (than a $mailto variable) for email addressing.
Ken,
Thanks for the update, but… my host does not allow url_fopen . I tried pasting in the UVF_fetchUrlWithoutHanging function into the script (from the latest get_UV_forcast_inc.php) and renaming it to GRC_… , but whilst I now get the captcha images and can submit, my mail is not sent and I just get asked to recheck the details of my message and then resubmit. Do you have any ideas on what I can do?
Thanks,
Chris
Ken,
I was about to send you my modified file, but I thought that I would first RFTM to show why my provider prohibited url_fopen and found how to change their default of allow_URL_fopen from off to ON. Low and behold - your original script now works as expected. My bad, sorry for the inconvenience :oops:
Chris