Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: pirc-bw on May 02, 2020, 12:14:37 AM

Title: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 12:14:37 AM
My SMF board is down after getting 16 SMF could not connect to the database messages this evening.
My host GoDaddy has informed me that there has been a change to the Index.PHP file which is preventing it from connecting to the database.

This is what they are telling me.
HP Notice: Undefined variable: boarddir in /home/k4fw0oj9jhy9/public_html/index.php on line 47 [02-May-2020 03:33:11 UTC] PHP Notice: Undefined variable: sourcedir in /home/k4fw0oj9jhy9/public_html/index.php on line 51 [02-May-2020 03:33:11 UTC] PHP Warning: require_once(/QueryString.php): failed to open stream: No such file or directory in /home/k4fw0oj9jhy9/public_html/index.php on line 51

I am not a pro at this kind of thing.  How do I fix this, any help would be appreciated.

https://bw-forums.com
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: vbgamer45 on May 02, 2020, 12:20:34 AM
Is your settings.php file empty?

If so grab from the backup settings_bak.php or from a backup that you have.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 12:24:23 AM
File manager says both files have 0 bytes
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: vbgamer45 on May 02, 2020, 12:29:04 AM
Do you have a backup?
If not grab a settings.php from the zip for SMF.
And enter in your SMF database connection information
And I would suggest then run the repair settings tool
What is repair_settings.php? (https://wiki.simplemachines.org/smf/Repair_settings.php)
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 12:38:10 AM
I have a settings template, but all it has is a list of Arrays
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: vbgamer45 on May 02, 2020, 12:44:08 AM
Here is an empty settings.php you need to run the repair settings tool to update.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 12:51:21 AM
Ok, I have that.  Do I delete the old one and just upload this one?
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: vbgamer45 on May 02, 2020, 12:57:36 AM
If it is empty yes.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 01:14:41 AM
Sorry for needing to go in baby steps.

I have uploaded the new file.  Now what do I do.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: vbgamer45 on May 02, 2020, 01:16:38 AM
Grab and upload repair settings.php to the root of your forum
Check steps here https://wiki.simplemachines.org/smf/Repair_settings.php



Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 01:24:00 AM
Ok I have that.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: vbgamer45 on May 02, 2020, 01:34:51 AM
Now on the repair settings page you have to fill in your database connection information from your control panel.
Then it should work after you hit save.

Then you must remove repair_settings.php !

I am off to rest now though.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 01:51:01 AM
Ok, thanks.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 05:57:17 AM
Do not forget to reupload a fresh index.php file as well afterwards.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Illori on May 02, 2020, 06:06:33 AM
Quote from: doug_ips on May 02, 2020, 05:57:17 AM
Do not forget to reupload a fresh index.php file as well afterwards.

that is not required. this is not from a hacking it is an issue with SMF coding.

you only need to replace the Settings.php file and you are good to go.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 06:28:17 AM
Quote from: Illori on May 02, 2020, 06:06:33 AM
Quote from: doug_ips on May 02, 2020, 05:57:17 AM
Do not forget to reupload a fresh index.php file as well afterwards.

that is not required. this is not from a hacking it is an issue with SMF coding.

you only need to replace the Settings.php file and you are good to go.

As per the first post. It looks like the index.php file has been corrupted. I suggested it in case the correction of the Settings.php file did not fix the error.

 

Quote from: pirc-bw on May 02, 2020, 12:14:37 AM
My SMF board is down after getting 16 SMF could not connect to the database messages this evening.
My host GoDaddy has informed me that there has been a change to the Index.PHP file which is preventing it from connecting to the database.

This is what they are telling me.
HP Notice: Undefined variable: boarddir in /home/k4fw0oj9jhy9/public_html/index.php on line 47 [02-May-2020 03:33:11 UTC] PHP Notice: Undefined variable: sourcedir in /home/k4fw0oj9jhy9/public_html/index.php on line 51 [02-May-2020 03:33:11 UTC] PHP Warning: require_once(/QueryString.php): failed to open stream: No such file or directory in /home/k4fw0oj9jhy9/public_html/index.php on line 51

I am not a pro at this kind of thing.  How do I fix this, any help would be appreciated.

https://bw-forums.com
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Arantor on May 02, 2020, 06:58:28 AM
No, it does not look like index.php has been corrupted, it looks EXACTLY like the race condition that wipes out Settings.php and nothing else.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 07:52:15 AM
Quote from: Arantor on May 02, 2020, 06:58:28 AM
No, it does not look like index.php has been corrupted, it looks EXACTLY like the race condition that wipes out Settings.php and nothing else.

Dude, chill out. It looked like that to me.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Arantor on May 02, 2020, 09:32:42 AM
I don't chill out when I see people giving incorrect and possibly damaging advice, because who knows what mods will be broken by replacing index.php?
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 10:04:34 AM
Quote from: Arantor on May 02, 2020, 09:32:42 AM
I don't chill out when I see people giving incorrect and possibly damaging advice, because who knows what mods will be broken by replacing index.php?

It was definitely not a damaging advice. Anyways, you really need to take a chill pill dude, and while you are at it, you need to adjust your attitude and ego too.

Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Arantor on May 02, 2020, 10:17:42 AM
Fair enough, bye.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Illori on May 02, 2020, 11:25:29 AM
Quote from: doug_ips on May 02, 2020, 10:04:34 AM
Quote from: Arantor on May 02, 2020, 09:32:42 AM
I don't chill out when I see people giving incorrect and possibly damaging advice, because who knows what mods will be broken by replacing index.php?

It was definitely not a damaging advice. Anyways, you really need to take a chill pill dude, and while you are at it, you need to adjust your attitude and ego too.



yes it really could be if a mod or mods modified that file. all those edits would be removed and could actually break the forum OP is running.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 11:45:22 AM
Quote from: Illori on May 02, 2020, 11:25:29 AM
Quote from: doug_ips on May 02, 2020, 10:04:34 AM
Quote from: Arantor on May 02, 2020, 09:32:42 AM
I don't chill out when I see people giving incorrect and possibly damaging advice, because who knows what mods will be broken by replacing index.php?

It was definitely not a damaging advice. Anyways, you really need to take a chill pill dude, and while you are at it, you need to adjust your attitude and ego too.



yes it really could be if a mod or mods modified that file. all those edits would be removed and could actually break the forum OP is running.

That is true, I agree. However, my advice was based on my understanding of the first post that the index.php file has been corrupted. i.e. emptied out. In that case all mod edits that might have been there would have been long gone and by replacing it with a fresh file as per my suggestion, would not cause any harm at all. All the OP had to do in that case, is readd the changes again.

If the repopulating of the Settings.php file will bring the forum backup online then the replace of the index.php file is not needed. But if it won''t, then a reupload of said file might fix the error. This is always based on the reply by OP 's host about said file being corrupted, which was my take on it.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 12:40:47 PM
Hey guys, I am still stuck.

What would happen if I created an new database and pointed it there???
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Illori on May 02, 2020, 12:44:09 PM
Quote from: pirc-bw on May 02, 2020, 12:40:47 PM
Hey guys, I am still stuck.

What would happen if I created an new database and pointed it there???

you dont want to do that or you could loose your content which is in the database. do you have a backup of your Settings.php file that you can restore? if not then you need to reset your database password and use repair_settings.php to put that new password into the Settings.php file.

if you dont have a backup you could ask your host if they can restore just that ONE file from the backup they should be doing.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 12:46:46 PM
Quote from: pirc-bw on May 02, 2020, 12:40:47 PM
Hey guys, I am still stuck.

What would happen if I created an new database and pointed it there???

Did you run the repair_setting.php file and entered the correct db info?

Personally I would advice against creating a new database at this time. It is not necessary. But if you want to go that route, you must restore there the backup of your current database and still enter the db info at the Settings.php info.

P.s. What about the Setting_bak.php file, is it intact? If it is, rename it to Settings.php and see if it would fix the error and get your forum back up online.

Quote from: Arantor on May 02, 2020, 09:32:42 AM
I don't chill out when I see people giving incorrect and possibly damaging advice, because who knows what mods will be broken by replacing index.php?

I forgot to quote the post by the OP which makes my advice about replacing the index.php file very valid btw.

Quote from: pirc-bw on May 02, 2020, 12:24:23 AM
File manager says both files have 0 bytes
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 12:46:54 PM
It turns out that my co-admin does have an old one from January.  It's being uploaded now.

Repair settings didn't do anything.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 12:50:27 PM
Quote from: pirc-bw on May 02, 2020, 12:46:54 PM
It turns out that my co-admin does have an old one from January.  It's being uploaded now.

Repair settings didn't do anything.

You should note that by restoring an older backup file, you will loose all content required from the time of that backup till now.

Anyways, how about the Settings_bak.php file, did you try that out? If all the db info are entered correct and you still get the connection error, check if the db user has full permission to the db that it is assigned to.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 12:53:12 PM
The .bak file was also empty.  Should we also upload an old version if my co-admin has that?
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 12:54:23 PM
Quote from: pirc-bw on May 02, 2020, 12:53:12 PM
The .bak file was also empty.  Should we also upload an old version if my co-admin has that?

By older version you mean a copy of the Settings.php file? If so by all means. If no db info has been changed in meanwhile it should do the trick.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 12:59:29 PM
Ok, thanks.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 01:32:34 PM
Quote from: pirc-bw on May 02, 2020, 12:59:29 PM
Ok, thanks.

No problem. Let us know how it will go.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 01:36:50 PM
So far nothing has changed except that I am getting a message about not being able to connect to the database, where before it was just a blank white page.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 01:45:21 PM
Quote from: pirc-bw on May 02, 2020, 01:36:50 PM
So far nothing has changed except that I am getting a message about not being able to connect to the database, where before it was just a blank white page.

That error occurs because either the db info are incorrectly set at the Settings.php file, or there are too many connections on the server. i.e. the problem lies with your host.

Are you really sure that the db info are set correctly at the Settings.php file? Did you check and make sure that the db user has been granted full access and privileges to the db?
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 01:49:29 PM
I just checked again.  The user has full privileges.   
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 01:55:35 PM
Quote from: pirc-bw on May 02, 2020, 01:49:29 PM
I just checked again.  The user has full privileges.

This is strange. If the db info are set correct at the Settings.php file and the db user has full access to the db the error should not occur. Unless it is a hosting issue.

Amyways, I can take a look at this for you if you want. Hit me with a pm in a couple of hours, as right now I do not have much free time. But first read this link though before you give someone access to your forum.

https://www.simplemachines.org/community/index.php?topic=190255.0
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Illori on May 02, 2020, 01:56:02 PM
then ask your host to look into it, you may need to change the database password and put it in Settings.php file.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: vbgamer45 on May 02, 2020, 02:15:23 PM
What tables do you have in the database? What is the prefix is it "smf_" ?
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 02:40:38 PM
That's the correct prefix.

I created a new user for it and gave it full privileges and then plugged that into the Repair settings.  Now I get "Table 'i4769326_sm1.smf_settings' doesn't exist"
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 02:48:19 PM
I am thinking it's time to start over from scratch.  Time consuming but will fix it.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 02:50:31 PM
Quote from: pirc-bw on May 02, 2020, 02:40:38 PM
That's the correct prefix.

I created a new user for it and gave it full privileges and then plugged that into the Repair settings.  Now I get "Table 'i4769326_sm1.smf_settings' doesn't exist"

Can you check your db and see if said table is indeed missing? If it is, the best way to restore it is to take it of your most recent backup file and readd it to your db.

Or you can readd it and all the default settings with the code taken from the install sql file, but the issue with it is that any settings that your installed mods have added will be missing.

CREATE TABLE {$db_prefix}settings (
  variable varchar(255) NOT NULL default '',
  value text NOT NULL,
  PRIMARY KEY (variable(30))
) ENGINE=MyISAM;

#
# Dumping data for table `settings`
#

INSERT INTO {$db_prefix}settings
(variable, value)
VALUES ('smfVersion', '{$smf_version}'),
('news', '{$default_news}'),
('compactTopicPagesContiguous', '5'),
('compactTopicPagesEnable', '1'),
('enableStickyTopics', '1'),
('todayMod', '1'),
('karmaMode', '0'),
('karmaTimeRestrictAdmins', '1'),
('enablePreviousNext', '1'),
('pollMode', '1'),
('enableVBStyleLogin', '1'),
('enableCompressedOutput', '{$enableCompressedOutput}'),
('karmaWaitTime', '1'),
('karmaMinPosts', '0'),
('karmaLabel', '{$default_karmaLabel}'),
('karmaSmiteLabel', '{$default_karmaSmiteLabel}'),
('karmaApplaudLabel', '{$default_karmaApplaudLabel}'),
('attachmentSizeLimit', '128'),
('attachmentPostLimit', '192'),
('attachmentNumPerPostLimit', '4'),
('attachmentDirSizeLimit', '10240'),
('attachmentUploadDir', '{$boarddir}/attachments'),
('attachmentExtensions', 'doc,gif,jpg,mpg,pdf,png,txt,zip'),
('attachmentCheckExtensions', '0'),
('attachmentShowImages', '1'),
('attachmentEnable', '1'),
('attachmentEncryptFilenames', '1'),
('attachmentThumbnails', '1'),
('attachmentThumbWidth', '150'),
('attachmentThumbHeight', '150'),
('censorIgnoreCase', '1'),
('mostOnline', '1'),
('mostOnlineToday', '1'),
('mostDate', UNIX_TIMESTAMP()),
('allow_disableAnnounce', '1'),
('trackStats', '1'),
('userLanguage', '1'),
('titlesEnable', '1'),
('topicSummaryPosts', '15'),
('enableErrorLogging', '1'),
('max_image_width', '0'),
('max_image_height', '0'),
('onlineEnable', '0'),
('cal_enabled', '0'),
('cal_maxyear', '2030'),
('cal_minyear', '2008'),
('cal_daysaslink', '0'),
('cal_defaultboard', ''),
('cal_showholidays', '1'),
('cal_showbdays', '1'),
('cal_showevents', '1'),
('cal_showweeknum', '0'),
('cal_maxspan', '7'),
('smtp_host', ''),
('smtp_port', '25'),
('smtp_username', ''),
('smtp_password', ''),
('mail_type', '0'),
('timeLoadPageEnable', '0'),
('totalMembers', '0'),
('totalTopics', '1'),
('totalMessages', '1'),
('simpleSearch', '0'),
('censor_vulgar', ''),
('censor_proper', ''),
('enablePostHTML', '0'),
('theme_allow', '1'),
('theme_default', '1'),
('theme_guests', '1'),
('enableEmbeddedFlash', '0'),
('xmlnews_enable', '1'),
('xmlnews_maxlen', '255'),
('hotTopicPosts', '15'),
('hotTopicVeryPosts', '25'),
('registration_method', '0'),
('send_validation_onChange', '0'),
('send_welcomeEmail', '1'),
('allow_editDisplayName', '1'),
('allow_hideOnline', '1'),
('guest_hideContacts', '1'),
('spamWaitTime', '5'),
('pm_spam_settings', '10,5,20'),
('reserveWord', '0'),
('reserveCase', '1'),
('reserveUser', '1'),
('reserveName', '1'),
('reserveNames', '{$default_reserved_names}'),
('autoLinkUrls', '1'),
('banLastUpdated', '0'),
('smileys_dir', '{$boarddir}/Smileys'),
('smileys_url', '{$boardurl}/Smileys'),
('avatar_directory', '{$boarddir}/avatars'),
('avatar_url', '{$boardurl}/avatars'),
('avatar_max_height_external', '65'),
('avatar_max_width_external', '65'),
('avatar_action_too_large', 'option_html_resize'),
('avatar_max_height_upload', '65'),
('avatar_max_width_upload', '65'),
('avatar_resize_upload', '1'),
('avatar_download_png', '1'),
('failed_login_threshold', '3'),
('oldTopicDays', '120'),
('edit_wait_time', '90'),
('edit_disable_time', '0'),
('autoFixDatabase', '1'),
('allow_guestAccess', '1'),
('time_format', '{$default_time_format}'),
('number_format', '1234.00'),
('enableBBC', '1'),
('max_messageLength', '20000'),
('signature_settings', '1,300,0,0,0,0,0,0:'),
('autoOptMaxOnline', '0'),
('defaultMaxMessages', '15'),
('defaultMaxTopics', '20'),
('defaultMaxMembers', '30'),
('enableParticipation', '1'),
('recycle_enable', '0'),
('recycle_board', '0'),
('maxMsgID', '1'),
('enableAllMessages', '0'),
('fixLongWords', '0'),
('knownThemes', '1,2,3'),
('who_enabled', '1'),
('time_offset', '0'),
('cookieTime', '60'),
('lastActive', '15'),
('smiley_sets_known', 'default,aaron,akyhne'),
('smiley_sets_names', '{$default_smileyset_name}\n{$default_aaron_smileyset_name}\n{$default_akyhne_smileyset_name}'),
('smiley_sets_default', 'default'),
('cal_days_for_index', '7'),
('requireAgreement', '1'),
('unapprovedMembers', '0'),
('default_personal_text', ''),
('package_make_backups', '1'),
('databaseSession_enable', '{$databaseSession_enable}'),
('databaseSession_loose', '1'),
('databaseSession_lifetime', '2880'),
('search_cache_size', '50'),
('search_results_per_page', '30'),
('search_weight_frequency', '30'),
('search_weight_age', '25'),
('search_weight_length', '20'),
('search_weight_subject', '15'),
('search_weight_first_message', '10'),
('search_max_results', '1200'),
('search_floodcontrol_time', '5'),
('permission_enable_deny', '0'),
('permission_enable_postgroups', '0'),
('mail_next_send', '0'),
('mail_recent', '0000000000|0'),
('settings_updated', '0'),
('next_task_time', '1'),
('warning_settings', '1,20,0'),
('warning_watch', '10'),
('warning_moderate', '35'),
('warning_mute', '60'),
('admin_features', ''),
('last_mod_report_action', '0'),
('pruningOptions', '30,180,180,180,30,0'),
('cache_enable', '1'),
('reg_verification', '1'),
('visual_verification_type', '3'),
('enable_buddylist', '1'),
('birthday_email', 'happy_birthday'),
('dont_repeat_theme_core', '1'),
('dont_repeat_smileys_20', '1'),
('dont_repeat_buddylists', '1'),
('attachment_image_reencode', '1'),
('attachment_image_paranoid', '0'),
('attachment_thumb_png', '1'),
('avatar_reencode', '1'),
('avatar_paranoid', '0');


Replace {$db_prefix} with your db actual prefix name.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 03:26:35 PM
I really appreciate your time and attempts to help. I did finally get the board to load again.  I am totally unsure why.

Now how to I prevent this from happening again.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 04:13:28 PM
Quote from: pirc-bw on May 02, 2020, 03:26:35 PM
I really appreciate your time and attempts to help. I did finally get the board to load again.  I am totally unsure why.

Now how to I prevent this from happening again.

Glad to see that you got it fixed.

You have to find out how it happened in the first place. Maybe it was a server glitch or something like that. Talk to your host and ask them to check their logs and see what happened.

Backing up your database regularly and forum files too will help a lot btw.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: pirc-bw on May 02, 2020, 04:17:37 PM
Thanks again.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Doug Heffernan on May 02, 2020, 04:24:00 PM
Quote from: pirc-bw on May 02, 2020, 04:17:37 PM
Thanks again.

You are welcome.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Illori on May 02, 2020, 04:39:50 PM
it happened because of a race condition in SMF. this was said already in this topic. contacting the host will NOT help to determine why it happened.

to keep it from happening is to set the Settings.php file as read only.

be sure to take a backup so if it happens again you can restore the file.
Title: Re: SMF board is down after getting multiple messages "SMF could not connect to the
Post by: Kindred on May 02, 2020, 09:10:51 PM
It actually could have been....   if the OP has installed mods which edit index.php