wendyv Posted September 4, 2015 Share Posted September 4, 2015 Hai! Over a few months, every now and then i can't log in in my shop. Last time i waited a few days (instead of install de shop again as i did earlier) and within 3 or 4 days i could log in again. Since yesterday i have the same problem. When i want to log in the page keeps loading en then just stops, screen doesn't even change. When i try to log in with a false username and password i get an alert that the username and password are incorrect (which is good). I looked up my error log and find this warning: PHP Warning: mysqli_connect(): (HY000/1040): Too many connections in /home/..... Can anyone help me solve this error? I currently use: * OScommerce 2.3.4 * PHP-versie: 5.5.23 Txs in advance! Greetz,Wendy Link to comment Share on other sites More sharing options...
Hotclutch Posted September 4, 2015 Share Posted September 4, 2015 Too many connections - speak to your host to have a look at the SQL server. Link to comment Share on other sites More sharing options...
wendyv Posted September 4, 2015 Author Share Posted September 4, 2015 Txs! I knew it was them! I have been discussing this with them for weeks! Link to comment Share on other sites More sharing options...
wendyv Posted September 6, 2015 Author Share Posted September 6, 2015 @@Hotclutch i contacted my host, but they told me that the problem is in a script.This would be the answer that could solve my problem he said. But i do not know which file i need to addept. Do you know anything about sql? "Too many connections" indicates, that your script is opening at least more than one connection to the database. Basically, to one server, only one connection is needed. Getting this error is either a misconfiguration of the server (which I assume isn't the case because max connections = zero isn't an option) or some programming errors in your script. Check for re-openings of your database connections (mysqli_connect). There should only be one per script (!) and usually you should take care of reusing open connections OR close them properly after script execution (mysqli_close) This is my database.php <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2013 osCommerce Released under the GNU General Public License */ function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') { global $$link; if (USE_PCONNECT == 'true') { $server = 'p:' . $server; } $$link = mysqli_connect($server, $username, $password, $database); if ( !mysqli_connect_errno() ) { mysqli_set_charset($$link, 'utf8'); } return $$link; } function tep_db_close($link = 'db_link') { global $$link; return mysqli_close($$link); } function tep_db_error($query, $errno, $error) { global $logger; if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { $logger->write('[' . $errno . '] ' . $error, 'ERROR'); } die('<font color="#000000"><strong>' . $errno . ' - ' . $error . '<br /><br />' . $query . '<br /><br /><small><font color="#ff0000">[TEP STOP]</font></small><br /><br /></strong></font>'); } function tep_db_query($query, $link = 'db_link') { global $$link, $logger; if (defined('STORE_DB_TRANSACTIONS') && (STORE_DB_TRANSACTIONS == 'true')) { if (!is_object($logger)) $logger = new logger; $logger->write($query, 'QUERY'); } $result = mysqli_query($$link, $query) or tep_db_error($query, mysqli_errno($$link), mysqli_error($$link)); return $result; } function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $link = 'db_link') { reset($data); if ($action == 'insert') { $query = 'insert into ' . $table . ' ('; while (list($columns, ) = each($data)) { $query .= $columns . ', '; } $query = substr($query, 0, -2) . ') values ('; reset($data); while (list(, $value) = each($data)) { switch ((string)$value) { case 'now()': $query .= 'now(), '; break; case 'null': $query .= 'null, '; break; default: $query .= '\'' . tep_db_input($value) . '\', '; break; } } $query = substr($query, 0, -2) . ')'; } elseif ($action == 'update') { $query = 'update ' . $table . ' set '; while (list($columns, $value) = each($data)) { switch ((string)$value) { case 'now()': $query .= $columns . ' = now(), '; break; case 'null': $query .= $columns .= ' = null, '; break; default: $query .= $columns . ' = \'' . tep_db_input($value) . '\', '; break; } } $query = substr($query, 0, -2) . ' where ' . $parameters; } return tep_db_query($query, $link); } function tep_db_fetch_array($db_query) { return mysqli_fetch_array($db_query, MYSQLI_ASSOC); } function tep_db_result($result, $row, $field = '') { if ( $field === '' ) { $field = 0; } tep_db_data_seek($result, $row); $data = tep_db_fetch_array($result); return $data[$field]; } function tep_db_num_rows($db_query) { return mysqli_num_rows($db_query); } function tep_db_data_seek($db_query, $row_number) { return mysqli_data_seek($db_query, $row_number); } function tep_db_insert_id($link = 'db_link') { global $$link; return mysqli_insert_id($$link); } function tep_db_free_result($db_query) { return mysqli_free_result($db_query); } function tep_db_fetch_fields($db_query) { return mysqli_fetch_field($db_query); } function tep_db_output($string) { return htmlspecialchars($string); } function tep_db_input($string, $link = 'db_link') { global $$link; return mysqli_real_escape_string($$link, $string); } function tep_db_prepare_input($string) { if (is_string($string)) { return trim(stripslashes($string)); } elseif (is_array($string)) { reset($string); while (list($key, $value) = each($string)) { $string[$key] = tep_db_prepare_input($value); } return $string; } else { return $string; } } function tep_db_affected_rows($link = 'db_link') { global $$link; return mysqli_affected_rows($$link); } function tep_db_get_server_info($link = 'db_link') { global $$link; return mysqli_get_server_info($$link); } if ( !function_exists('mysqli_connect') ) { define('MYSQLI_ASSOC', MYSQL_ASSOC); function mysqli_connect($server, $username, $password, $database) { if ( substr($server, 0, 2) == 'p:' ) { $link = mysql_pconnect(substr($server, 2), $username, $password); } else { $link = mysql_connect($server, $username, $password); } if ( $link ) { mysql_select_db($database, $link); } return $link; } function mysqli_connect_errno($link = null) { if ( is_null($link) ) { return mysql_errno(); } return mysql_errno($link); } function mysqli_connect_error($link = null) { if ( is_null($link) ) { return mysql_error(); } return mysql_error($link); } function mysqli_set_charset($link, $charset) { if ( function_exists('mysql_set_charset') ) { return mysql_set_charset($charset, $link); } } function mysqli_close($link) { return mysql_close($link); } function mysqli_query($link, $query) { return mysql_query($query, $link); } function mysqli_errno($link = null) { if ( is_null($link) ) { return mysql_errno(); } return mysql_errno($link); } function mysqli_error($link = null) { if ( is_null($link) ) { return mysql_error(); } return mysql_error($link); } function mysqli_fetch_array($query, $type) { return mysql_fetch_array($query, $type); } function mysqli_num_rows($query) { return mysql_num_rows($query); } function mysqli_data_seek($query, $offset) { return mysql_data_seek($query, $offset); } function mysqli_insert_id($link) { return mysql_insert_id($link); } function mysqli_free_result($query) { return mysql_free_result($query); } function mysqli_fetch_field($query) { return mysql_fetch_field($query); } function mysqli_real_escape_string($link, $string) { if ( function_exists('mysql_real_escape_string') ) { return mysql_real_escape_string($string, $link); } elseif ( function_exists('mysql_escape_string') ) { return mysql_escape_string($string); } return addslashes($string); } function mysqli_affected_rows($link) { return mysql_affected_rows($link); } function mysqli_get_server_info($link) { return mysql_get_server_info($link); } } ?> Link to comment Share on other sites More sharing options...
Hotclutch Posted September 6, 2015 Share Posted September 6, 2015 Does the problem go away when you run a standard database.php? Yours' is modified, and may be the problem as such, unfortunately the mod you made is unknown to me, so can't give input. Link to comment Share on other sites More sharing options...
wendyv Posted September 7, 2015 Author Share Posted September 7, 2015 No it doesn't. I had these problems from the start (clean oscommerce 2.3.4 install) Link to comment Share on other sites More sharing options...
Hotclutch Posted September 7, 2015 Share Posted September 7, 2015 If you had this problem with a clean install, then it must be a hosting problem. Remember you are on shared hosting, and not the only one making connections to the database server. Link to comment Share on other sites More sharing options...
♥toyicebear Posted September 7, 2015 Share Posted September 7, 2015 also check that persistent connections is off in includes/configuration.php Basics for osC 2.2 Design - Basics for Design V2.3+ - Seo & Sef Url's - Meta Tags for Your osC Shop - Steps to prevent Fraud... - MS3 and Team News... - SEO, Meta Tags, SEF Urls and osCommerce - Commercial Support Inquiries - OSC 2.3+ How To To see what more i can do for you check out my profile [click here] Link to comment Share on other sites More sharing options...
tgely Posted September 8, 2015 Share Posted September 8, 2015 could you switch admin session handling to '' in configure.php? dont forget to config the right sessions directory in sessions configuration before! change: define('STORE_SESSIONS', 'mysql'); to: define('STORE_SESSIONS', ''); osCommerce based shop owner with minimal design and focused on background works. When the less is more.Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.