UBBCentral
Posted By: Basil Help with database error - 03/24/2018 10:44 PM
Hi guys, it's been a while since I've been here but I am hoping someone can help me resolve an issue. I have a backup of an older UBB version. I had all the files backed up and the database backed up. I recently had a need to temporarily re-install that from backups to look at something in my forum posts there, but have run into a snag.

I have uploaded all the files and database to my server, but when I try to go to my forum index file I get the following (See attached)/ In case the attachment doesn't work, it basically says:

UBB Message
We encountered a problem. The reason reported was
Database error only visible to forum administrators
Please click back to return to previous page.

My question to you all is, how can I see this error when I can't get logged in? In cPanel, the error log doesn't show any database errors so maybe DB error are accessible from somewhere else? Any help is greatly appreciated.

UPDATE: Upon closer look, I did find a related error in error logs:

[Sat Mar 24 18:26:23.737975 2018] [cgi:error] [pid 11836] [client XX.XX.XX.XX:XXXX] AH01215: PHP Fatal error: Call to a member function error() on null in /home/xyz/public_html/ubforum/libs/mysql.inc.php on line 77: /usr/local/cpanel/cgi-sys/ea-php56, referer: http://www.blahblah.com/ubforum/admin/

Line 77 seems to be the $admin->error( $errstr ) in the following code:

PHP Code
global $admin, $html;

		if (defined('IS_ADMIN')) {
			$admin->error( $errstr );
		} else if (defined('IS_IMPORT') || defined('IS_UPGRADE')) {
			echo '<b>SQL Error:</b> ' . $errstr;
		} else {
			if (!is_object($html)) {
				$html = new html;
			}

			if (defined('NO_WRAPPERS')) $is_bare = true;

			( $is_bare ? $html->not_right_bare( $errstr ) : $html->not_right( $errstr ) );
		}
	} 



Attached picture Screen Shot 2018-03-24 at 4.33.30 PM.jpeg
Posted By: Gizmo Re: Help with database error - 03/24/2018 10:56 PM
To display errors when MySQL logging is off (or hasn't been enabled) you'd need to make a small change to an embedded variable
In /libs/mysql.inc.php change:
Code
$showerror = 0;


to
Code
$showerror = 1;


You'll want to reverse this change once everything is worked out.
Posted By: Basil Re: Help with database error - 03/24/2018 11:46 PM
Thanks for that! I guess either I didn't download the entire DB or when I tried to re-import it, it didn't import all the way because the error is:

SQL Error: Table 'xyz_threadsv7.ubbt_USERS' doesn't exist

Looks like all the tables didn't import (Or if I screwed up when I did the last backup I may be screwed unless I get lucky and can find an older DB backup.
Posted By: Gizmo Re: Help with database error - 03/24/2018 11:53 PM
Is the current database named "xyz_threadsv7"?
Posted By: Basil Re: Help with database error - 03/25/2018 12:33 AM
Yes and no. the xyz is really something else, but I obfuscated it for posting on a public forum. But the database in question has the exact same name as was in the error. Now, I just tried to re-import the database to see if I can all the tables, but I got this in PhPMyAdmin:

SQL query:


--
-- Dumping data for table `ubbt_ANNOUNCEMENTS`
--

INSERT INTO `ubbt_ANNOUNCEMENTS` (`TOPIC_ID`, `FORUM_ID`) VALUES
(5343, '22'),
(6770, '20'),
(6779, '17'),
(7580, '23'),
(15561, '26'),


MySQL said:

#1062 - Duplicate entry '5343-22' for key 'a_index'


Do I need to delete and re-create a DB before I try to import it again?
Posted By: Gizmo Re: Help with database error - 03/25/2018 12:39 AM
Are you attempting to import a backup through PHPMyAdmin? You'll likely hit the PHP max execute time if using a large database.

I would recommend importing a database via command line vs through a web script; I have some instructions in the "Import Database section of the "Migration Guide" at UBBWiki:
Quote
Now that the old files are on the new server, you need to import your database; you can again use PHPMyAdmin or use the command line to import the database. The command line way of doing this (note, this is not the MySQL command line, simply the Linux command line) would be:
Code
mysql -h localhost -uuser -ppass database_name < databasebackupfile.sql
Posted By: Basil Re: Help with database error - 03/25/2018 12:50 AM
Ok, I'll try that but I have a sinking feeling that when I did the backup I didn't get the entire DB
Posted By: Gizmo Re: Help with database error - 03/25/2018 12:52 AM
Entirely possible if you did it through PHPMyAdmin and the database wasnt fully exported. I generally either export/import via command line or SQLYog (when SSH access is not provided).
Posted By: Gizmo Re: Help with database error - 03/25/2018 4:02 AM
It'll also throw an already exists error if you're importing into a database which already has data in it as you cannot import a UBB.threads database over a UBB.threads database.
Posted By: Ruben Re: Help with database error - 03/25/2018 9:04 PM
Basil,
You also need to undo the show error that Gizmo showed you.
It is a temporary measure if you don't have error logs turned on.
It will show any member/guest the same info.
Posted By: Basil Re: Help with database error - 03/27/2018 1:45 AM
Thanks guys. I think I have to conclude that when I backed up the db I did not get the entire db so am essentially dead in the water. Oh well, lesson learned (PS: I did turn off the debug).
© 2019 UBB.threads PHP Forum Software Community