Exeded max mysql connections?!?


#1

The mysql user i use in my scripts is exeding max_user_connections.

Ok… i think it might be a ddos.
If not how can i close all conections of one certain user?
BTW, how can i check this maximum value?

http://shareminer.com


#2

How do you instantiate your connection to the database? IMHO this seems less likely to be a ddos attempt than a slight mistake in your code. Do you make sure that you check for the existance of a connection before instantiating a new one? Unless something about php as cgi makes me wrong here, you usually will only need one connection between the webserver and the database.

It’s reused for successive database operations which is why you can pass a reference to the data connection object between multiple functions. Here’s an example of how I do some of my interaction, and haven’t ever seen more than one connection to MySQL created… in addition to my login via phpMyAdmin of course.

Maybe a sample of your code would be useful?

[code]CODE FROM: zipData.php

<?php // include db and query components require_once("qryMySQLConn.php"); require_once("qryDataUDF.php"); $rsZipDtl = getZipDetail($_GET[userString]); if ( $rsZipDtl ) { for ($i=0; $izipID|$ntRowObj->zipRLongitude|$ntRowObj->zipRLatitude"; } } echo($cLineStr); ?>

CODE FROM: qryMySQLConn.php

<?php if ( !isset($db) ) { define ('DB_USER', 'user'); define ('DB_PASS', 'pass'); define ('DB_NAME', 'dbname'); define ('DB_HOST', 'dbhost'); $db = mysql_connect (DB_HOST, DB_USER, DB_PASS); mysql_select_db (DB_NAME); } ?>

CODE FROM: qryDataUDF.php

<?php function getZipDetail($zipCode) { $queryStr = "*THE QUERY*"; $result = mysql_query($queryStr); if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $queryStr; die($message); } return $result; } ?>

[/code]