[English] A Database Error Occurred

277 views
Skip to first unread message

william....@yunussb.com

unread,
Jun 26, 2018, 11:09:49 AM6/26/18
to jorani
Hello guys,

I'm facing a problem with the implementation of Jorani on our website. It is giving me this error from 18 June:
A Database Error Occurred

Unable to connect to your database server using the provided settings.

Filename: core/Loader.php

Line Number: 347


It was implemented from our previous IT responsible and worked well until I tried to update the PHP version from 5.5 to 7.1, then I tried to downgrade to 5.5 again, but the problem still exists.


I checked the line that is outlined in the error message:


        $CI->db =& DB($params, $active_record);


But unfortunately, I don't have the PHP skills to understand it. If someone could help me to figure out how to solve this issue, I would be thankful forever!

Philippe Mignon

unread,
Jun 27, 2018, 8:35:12 AM6/27/18
to jorani
Hello,
not sure but it seems to be a SQL Datebase problem.
Which is your version of Jorani ?
What does the page /requirements.php show you ?
Philippe

william....@yunussb.com

unread,
Jun 27, 2018, 11:13:47 AM6/27/18
to jorani
Hello, thank you for your answer.

I'll answer your questions below.

Inside the root of the website there is a folder named jorani-0.4.6, I suppose this is the current version.

This is the content of the file requirements.php

<?php
/**
 * This diagnostic page helps you to check your setup.
 * @copyright  Copyright (c) 2014-2016 Benjamin BALET
 * @license      http://opensource.org/licenses/AGPL-3.0 AGPL-3.0
 * @link            https://github.com/bbalet/jorani
 * @since         0.3.0
 */


define
('BASEPATH','.');//Make this script works with nginx

if (function_exists('apache_get_modules')) {
  $modules
= apache_get_modules();
  $mod_rewrite
= in_array('mod_rewrite', $modules);
} else {
  $mod_rewrite
=  getenv('HTTP_MOD_REWRITE')=='On' ? true : false ;
}

$allow_overwrite
=  getenv('ALLOW_OVERWRITE');
$mod_rewrite
=  getenv('HTTP_MOD_REWRITE');
$server_software
= getenv('SERVER_SOFTWARE');
$mod_gzip
= getenv('HTTP_MOD_GZIP');

if ($mod_rewrite == "") $mod_rewrite = '<b>.htaccess not visited</b>';
if ($allow_overwrite == "") $allow_overwrite = '<b>Off</b>';

$tmz
= @date_default_timezone_get();

//Check if we can access to the configuration file
$pathConfigFile
= realpath(join(DIRECTORY_SEPARATOR, array('application', 'config', 'database.php')));
$configFileExists
= file_exists($pathConfigFile);
$dbConnError
= TRUE;
$dbSelectDbError
= TRUE;
$dbQueryError
= TRUE;
$dbProcsError
= TRUE;

if ($configFileExists) {
    include $pathConfigFile
;
   
//Try to connect to database
    $dbConn
= new mysqli($db['default']['hostname'], $db['default']['username'], $db['default']['password']);
    $dbConnError
= mysqli_connect_errno() ? TRUE : FALSE;
   
if (!$dbConnError) {
        $dbConn
->select_db($db['default']['database']);
        $dbSelectDbError
= ($dbConn->errno > 0) ? TRUE : FALSE;
       
//Try to get the signature of the schema
       
if (!$dbSelectDbError) {
           
//Examine organization structure
            $resultOrg
= $dbConn->query("SELECT id FROM organization WHERE parent_id=-1");
            $rowOrg
= $resultOrg->fetch_assoc();
            $resultOrg
->free();;
           
           
//Try to use a procedure in order to check the install script
           
//We don't know if the user has access to information schema
           
//So we try to call one of the procedures with a parameter returning a small set of results
            $dbConn
->query("SELECT GetParentIDByID(0) AS result");
            $dbProcsError
= ($dbConn->errno > 0) ? TRUE : FALSE;
           
            $sql
= "SELECT TABLE_NAME, MD5(GROUP_CONCAT(CONCAT(TABLE_NAME, COLUMN_NAME, COALESCE(COLUMN_DEFAULT, ''), IS_NULLABLE, COLUMN_TYPE, COALESCE(COLLATION_NAME, '')) SEPARATOR ', ')) AS signature"
                   
. " FROM information_schema.columns"
                   
. " WHERE table_schema =  DATABASE()"
                   
. " GROUP BY TABLE_NAME"
                   
. " ORDER BY TABLE_NAME";
            $stmt
= $dbConn->prepare($sql);
            $dbQueryError
= ($dbConn->errno > 0) ? TRUE : FALSE;
           
if (!$dbQueryError) {
                $stmt
->execute();
                $dbQueryError
= ($dbConn->errno > 0) ? TRUE : FALSE;
           
}
           
if (!$dbQueryError) {
                $stmt
->bind_result($table, $signature);
                $dbQueryError
= ($dbConn->errno > 0) ? TRUE : FALSE;
           
}
       
}
   
}
}
?>
<html>
   
<head>
   
<title>Jorani Requirements</title>
   
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
   
<meta charset="UTF-8">
   
<link rel="icon" type="image/x-icon" href="favicon.ico" sizes="32x32">
   
<link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">
   
<script type="text/javascript" src="assets/js/jquery-1.11.0.min.js"></script>
   
   
<script type="text/javascript">
       
function export2csv() {
       
var content = "";
        content
+= "Table;Description;Value\n";

        $
("#tblServer tr").each(function() {
          $this
= $(this)
          content
+= "Server;" + $.trim($(this).find("td:eq(0)").text())
                 
+ ";" + $(this).find("td:eq(1)").text()  + "\n";
       
});
        $
("#tblDatabase tr").each(function() {
          $this
= $(this)
          content
+= "Database;" + $.trim($(this).find("td:eq(0)").text())
                 
+ ";" + $(this).find("td:eq(1)").text()  + "\n";
       
});
        $
("#tblSchema tr").each(function() {
          $this
= $(this)
          content
+= "Schema;" + $.trim($(this).find("td:eq(0)").text())
                 
+ ";" + $(this).find("td:eq(1)").text()  + "\n";
       
});

       
// Build a data URI:
        uri
= "data:text/csv;charset=utf-8," + encodeURIComponent(content);
        location
.href = uri;
   
}
   
</script>
   
</head>
   
<body>
       
<div class="container-fluid">
           
<ul class="nav nav-pills">
               
<li class="active"><a href="#">Requirements</a></li>
               
<li><a href="testmail.php">Email</a></li>
               
<li><a href="testldap.php">LDAP</a></li>
               
<li><a href="testssl.php">SSL</a></li>
               
<li><a href="testoauth2.php">OAuth2</a></li>
               
<li><a href="opcache.php">Opcache</a></li>
             
</ul>
           
<h1>Jorani Requirements</h1>

           
<noscript>
                Javascript is disabled. Jorani requires Javascript to be enabled.
           
</noscript>
           
<button class="btn btn-primary" onclick="export2csv();"><i class="icon-download-alt icon-white"></i>&nbsp;Export to a CSV file</button>
           
           
<h2>Web Server</h2>

           
<table class="table table-bordered table-hover table-condensed">
               
<thead>
                   
<tr>
                     
<th>Requirement</th>
                     
<th>Value / Description</th>
                   
</tr>
                 
</thead>
                 
<tbody id="tblServer">
                     
<tr><td><i class="icon-info-sign"></i>&nbsp;Server software</td><td><?php echo $server_software; ?></td></tr>

                     
<tr><td><?php if (strtolower($allow_overwrite) == "on") {?><i class="icon-ok-sign"></i><?php } else { ?><i class="icon-remove-sign"></i><?php } ?>
                      &nbsp;Allow overwrite (.htaccess files)
</td><td><?php echo $allow_overwrite; ?> (used for cool URLs) Ignore this message if you are running something else than Apache.</td></tr>

                     
<tr><td><?php if (strtolower($mod_rewrite) == "on") {?><i class="icon-ok-sign"></i><?php } else { ?><i class="icon-remove-sign"></i><?php } ?>
                      &nbsp;Apache module rewrite (mod_rewrite)
</td><td><?php echo $mod_rewrite; ?> (used for cool URLs) Ignore this message if you are running something else than Apache.</td></tr>

                     
<tr><td><?php if (strtolower($mod_gzip) == "on") {?><i class="icon-ok-sign"></i><?php } else { ?><i class="icon-remove-sign"></i><?php } ?>
                      &nbsp;Apache module gzip (mod_gzip)
</td><td><?php echo $mod_gzip; ?> Improve response times.</td></tr>
                     
                     
<?php if (version_compare(PHP_VERSION, '5.3.0') >= 0) {?>
                     
<tr><td><i class="icon-ok-sign"></i>&nbsp;PHP 5.3+</td>
                     
<?php } else { ?>
                     
<tr><td><i class="icon-remove-sign"></i>&nbsp;Old PHP version</td>
                     
<?php } ?><td>Ignore this message if you are running an exotic PHP runtime</td></tr>
                     
                     
<?php if (defined('HHVM_VERSION')) {?>
                       
<tr><td><i class="icon-info-sign"></i>&nbsp;HHVM</td><td><?php echo HHVM_VERSION; ?></td></tr>
                       
<?php } else { ?>
                       
<tr><td><i class="icon-info-sign"></i>&nbsp;PHP</td><td><?php echo PHP_VERSION; ?></td></tr>
                       
<?php } ?>
                       
                     
<?php if ($tmz != 'UTC') {?>
                     
<tr><td><i class="icon-ok-sign"></i>&nbsp;Timezone defined</td>
                     
<?php } else { ?>
                     
<tr><td><i class="icon-remove-sign"></i>&nbsp;Timezone undefined</td>
                     
<?php } ?><td>If error, please check date.timezone into PHP.ini.</td></tr>
                     
                     
<?php if (function_exists('mb_strimwidth')) {?>
                     
<tr><td><i class="icon-ok-sign"></i>&nbsp;<code>mb_strimwidth</code> function exists</td>
                     
<?php } else { ?>
                     
<tr><td><i class="icon-remove-sign"></i>&nbsp;<code>mb_strimwidth</code> function doesn't exist</td>
                     
<?php } ?><td>PHP must be compiled with <a href="http://php.net/manual/en/mbstring.installation.php" target="_blank">multibyte string support<a>.</td></tr>
                       
                     
<?php if (extension_loaded('mcrypt')) {?>
                     
<tr><td><i class="icon-ok-sign"></i>&nbsp;mcrypt is LOADED</td>
                     
<?php } else { ?>
                     
<tr><td><i class="icon-remove-sign"></i>&nbsp;mcrypt IS NOT LOADED.</td>
                     
<?php } ?><td>PHP Extension mcrypt is required for some security features.</td></tr>
                     
                     
<?php if (extension_loaded('Zend OPcache')) {?>
                     
<tr><td><i class="icon-ok-sign"></i>&nbsp;OPcache is LOADED</td>
                     
<?php } else { ?>
                     
<tr><td><i class="icon-exclamation-sign"></i>&nbsp;OPcache IS NOT LOADED.</td>
                     
<?php } ?><td>Please consider activating OPcache for the best performances.</td></tr>
                     
                     
<?php if (extension_loaded('openssl')) {?>
                     
<tr><td><i class="icon-ok-sign"></i>&nbsp;openssl is LOADED</td>
                     
<?php } else { ?>
                     
<tr><td><i class="icon-exclamation-sign"></i>&nbsp;openssl IS NOT LOADED.</td>
                     
<?php } ?><td>PHP Extension openssl speeds up the log in page.</td></tr>

                     
<?php if (extension_loaded('curl')) {?>
                     
<tr><td><i class="icon-ok-sign"></i>&nbsp;curl is LOADED</td>
                     
<?php } else { ?>
                     
<tr><td><i class="icon-exclamation-sign"></i>&nbsp;curl IS NOT LOADED.</td>
                     
<?php } ?><td>PHP Extension curl is needed for OAuth2 authentication.</td></tr>
                     
                     
<?php if (extension_loaded('ldap')) {?>
                     
<tr><td><i class="icon-ok-sign"></i>&nbsp;ldap is LOADED</td>
                     
<?php } else { ?>
                     
<tr><td><i class="icon-exclamation-sign"></i>&nbsp;ldap IS NOT LOADED</td>
                     
<?php } ?><td>PHP Extension ldap is optional and allows you to use LDAP for authentication.</td></tr>
                     
                     
<?php if (extension_loaded('zip')) {?>
                     
<tr><td><i class="icon-ok-sign"></i>&nbsp;zip is LOADED</td>
                     
<?php } else { ?>
                     
<tr><td><i class="icon-exclamation-sign"></i>&nbsp;zip IS NOT LOADED</td>
                     
<?php } ?><td>PHP Extension zip allows you to use the export to Excel feature.</td></tr>
                     
                     
<?php if (extension_loaded('xml')) {?>
                     
<tr><td><i class="icon-ok-sign"></i>&nbsp;xml is LOADED</td>
                     
<?php } else { ?>
                     
<tr><td><i class="icon-exclamation-sign"></i>&nbsp;xml IS NOT LOADED</td>
                     
<?php } ?><td>PHP Extension xml allows you to use the export to Excel feature.</td></tr>
                     
                     
<?php if (extension_loaded('gd')) {?>
                     
<tr><td><i class="icon-ok-sign"></i>&nbsp;gd is LOADED</td>
                     
<?php } else { ?>
                     
<tr><td><i class="icon-exclamation-sign"></i>&nbsp;gd IS NOT LOADED</td>
                     
<?php } ?><td>PHP Extension gd2 allows you to use the export to Excel feature.</td></tr>
                     
                     
<?php if (extension_loaded('mysqli')) {?>
                     
<tr><td><i class="icon-ok-sign"></i>&nbsp;mysqli is LOADED</td>
                     
<?php } else { ?>
                     
<tr><td><i class="icon-exclamation-sign"></i>&nbsp;mysqli IS NOT LOADED</td>
                     
<?php } ?><td>mysqli is the recommended database driver.</td></tr>
                 
</tbody>
           
</table>

           
<h2>Additional configuration</h2>
           
           
<p>You can test the following settings, but you need to edit the corresponding PHP scripts :</p>
           
<ul>
               
<li><a href="testssl.php" target="_blank">SSL Configuration and Utility.</a></li>
               
<li><a href="testoauth2.php" target="_blank">OAuth2 Settings.</a></li>
               
<li><a href="testmail.php" target="_blank">E-mail Settings.</a></li>
               
<li><a href="testldap.php" target="_blank">LDAP Settings.</a></li>
               
<li><a href="opcache.php" target="_blank">OPCache Tester.</a></li>
           
</ul>
           
           
<h2>Database</h2>

           
<table class="table table-bordered table-hover table-condensed">
               
<thead>
                   
<tr>
                     
<th>Requirement</th>
                     
<th>Value / Description</th>
                   
</tr>
                 
</thead>
                 
<tbody id="tblDatabase">
                     
<?php if ($configFileExists) { ?><tr><td><i class="icon-ok-sign"></i>&nbsp;Configuration file</td><td>Found</td></tr>
                     
<?php } else { ?><tr><td><i class="icon-remove-sign"></i>&nbsp;Configuration file</td><td>Not Found</td></tr>
                     
<?php } ?>
                     
                     
<?php if (!$dbConnError) { ?><tr><td><i class="icon-ok-sign"></i>&nbsp;Database connection</td><td>OK</td></tr>
                     
<?php } else { ?><tr><td><i class="icon-remove-sign"></i>&nbsp;Database connection</td><td>Error</td></tr>
                     
<?php } ?>
                     
                     
<?php if (!$dbSelectDbError) { ?><tr><td><i class="icon-ok-sign"></i>&nbsp;Database name</td><td>Found</td></tr>
                     
<?php } else { ?><tr><td><i class="icon-remove-sign"></i>&nbsp;Database name</td><td>Doesn't exist</td></tr>
                     
<?php } ?>

                     
<?php if (!$dbQueryError) { ?><tr><td><i class="icon-ok-sign"></i>&nbsp;Database query</td><td>OK</td></tr>
                     
<?php } else { ?><tr><td><i class="icon-remove-sign"></i>&nbsp;Database query</td><td>Error</td></tr>
                     
<?php } ?>
                     
                     
<?php if (!$dbProcsError) { ?><tr><td><i class="icon-ok-sign"></i>&nbsp;Database procedures</td><td>OK</td></tr>
                     
<?php } else { ?><tr><td><i class="icon-remove-sign"></i>&nbsp;Database procedures</td><td>Error. Please check if your hosting company allows custom procedures (e.g. <a href="https://techtavern.wordpress.com/2013/06/17/mysql-triggers-and-amazon-rds/" target="_blank">Amazon RDS</a>).</td></tr>
                     
<?php } ?>
                     
                     
<?php if (is_null($rowOrg)) { ?><tr><td><i class="icon-remove-sign"></i>&nbsp;Organization structure</td><td>No root entity was found.</td></tr>
                     
<?php } else { ?>
                           
<?php if ($rowOrg['id'] != 0) { ?><tr><td><i class="icon-remove-sign"></i>&nbsp;Organization structure</td><td>The root entity must be equal to zero. To fix a problem of backup/restore, please execute this query: <br />
                                   
<code>UPDATE `organization` SET `organization`.`id` = 0 WHERE `parent_id` = -1</code></td></tr>
                           
<?php } else { ?><tr><td><i class="icon-ok-sign"></i>&nbsp;Organization structure</td><td>OK</td></tr>
                     
<?php }
                           
}?>
                 
</tbody>
           
</table>
           
           
<h2>Schema</h2>

           
<table class="table table-bordered table-hover table-condensed">
               
<thead>
                   
<tr>
                     
<th>Table</th>
                     
<th>Signature</th>
                   
</tr>
                 
</thead>
                 
<tbody id="tblSchema">                      
<?php if (!$dbQueryError) {
   
while ($stmt->fetch()) {  ?>
               
<tr><td><i class="icon-info-sign"></i>&nbsp;<?php echo $table; ?></td><td><?php echo $signature; ?></td></tr>
<?php }
        $stmt
->close();
       
if (!$dbConnError) $dbConn->close();
       
} else { ?>
               
<tr><td colspan="2"><i>Impossible to query database</i></td></tr>
<?php } ?>
                 
</tbody>
           
</table>
       
</div>
   
</body>
</html>


Philippe MIGNON

unread,
Jun 27, 2018, 11:45:19 AM6/27/18
to william.mandarino via jorani
Hello,
just run the requirements.php file on your site if you can. The answer of the script in that file will give informations about your server ;-)
If you're using a 0.4.6 version, you'll need to update for a PHP 7 compatibility
This article could help you https://jorani.org/backup-restore-migration-guide.html

Philippe
--
You received this message because you are subscribed to a topic in the Google Groups "jorani" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jorani/JHZKGBwyhAY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jorani+un...@googlegroups.com.
To post to this group, send email to jor...@googlegroups.com.
Visit this group at https://groups.google.com/group/jorani.
To view this discussion on the web visit https://groups.google.com/d/msgid/jorani/0dc87ce8-ba44-4c96-84f3-fff3473e0c8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

william....@yunussb.com

unread,
Jun 28, 2018, 12:22:16 PM6/28/18
to jorani

Hello Philippe,

Well, I need instruction about how to run the requirement.php file if it is essential because I don't know how to do it.
What I did instead is an update to the php 7.0 version from cPanel, and then I check the troubleshooting section on the page you linked, and what I found is that I miss some Functions. The image below is from phpMyAdmin.











Thank you very much for your help, I appreciate it so much.

Benjamin BALET

unread,
Jun 28, 2018, 9:45:13 PM6/28/18
to jor...@googlegroups.com
Hi,

Your version of Jorani is not compatible with PHP7. So either you stay with PHP5 or you update to the latest version of Jorani.
If you need to access to the requirements script, add requirements.php at the end of your address.
For example, the demo is available at this address: http://demo.jorani.org/
Then the requirements script is available at this address: http://demo.jorani.org/requirements.php

In order to restore the MySQL functions only, you may use this script:

This script will delete and create the functions again.

--
You received this message because you are subscribed to the Google Groups "jorani" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jorani+un...@googlegroups.com.

To post to this group, send email to jor...@googlegroups.com.
Visit this group at https://groups.google.com/group/jorani.

william....@yunussb.com

unread,
Jul 2, 2018, 5:56:03 AM7/2/18
to jorani
Thank you for the answer Mr. Balet.

Since I tried to run the requirements.php script, and it returned a 404 error, I think that the best chance for me to learn something is to install the last version of Jorani and set it up from the scratch. I just have a question, I have exported all the important files (config.php, database.php, email.php) and also the databases through phpMyAdmin, will I be able to restore the information that we are using from this files if I install the last version?

Best regards.

Benjamin BALET

unread,
Jul 2, 2018, 5:59:42 AM7/2/18
to jor...@googlegroups.com
After restoring your SQL files, you will have to run the two patches so as to make your database compatible:
sql/patch_to_0.5.0.sql
sql/patch_to_0.6.0.sql

william....@yunussb.com

unread,
Jul 3, 2018, 10:09:52 AM7/3/18
to jorani
Hello and good afternoon,

I have some problem with the installation, or to be more clear, I don't get some steps.

I downloaded the .zip version from Github, extracted it on my Document folder (Local on my pc) and then I uploaded the content of the jorani-master folder to the /www (public_html) folder through Filezilla, and replaced just the files config.php, database.php and email.php from my previous backup.
Since my web server uses Apache I checked the mod_rewrite and I deleted the # symbol before the entry inside the file .htaccess, in order to activate it.

Now what I don't get comes:

  • Create a database with /sql/lms.sql script.
This step is obscure for me, and to be honest, I really don't understand how to run a script on my server, I already tried to follow your example, but I just get a 404 error message. This is the URL of the page "https://n1plcpnl0100.prod.ams1.secureserver.net/" but neither https://n1plcpnl0100.prod.ams1.secureserver.net/requirements.php nor https://n1plcpnl0100.prod.ams1.secureserver.net/public_html/requirements.php worked out.
Since I have an SSL certificate on this domain, I have changed  application/config/config.php $_SERVER['HTTPS'] = 'on';

Now I'm stuck here, I don't know how to run these scripts, and it makes me so frustrated. I also tried to check the documentation page and the YouTube channel again, but it is focused on how to set the tool after the installation.
Reply all
Reply to author
Forward
0 new messages