Hi, and thanks, I really appreciate your time. I have this function to connect to my BD. (funciones.php)
function conectarse() {
$conexion = mysqli_connect("localhost", "user", "pass", "DB") or die("Error de conexion: " . mysqli_connect_error());
if (!$conexion) {
return False;
}
return $conexion;
}And have this one to select data on my DB. (funciones.php)
function armame($date, $MarketName, $cod) {
$conexion=conectarse();
switch ($cod) {
case "24H":
$date2 = strtotime ( '-24 hour' , strtotime ( $date ) ) ;
$date2 = date ( 'Y-m-d H:i:s' , $date2 );
break;
case "4H":
$date2 = strtotime ( '-4 hour' , strtotime ( $date ) ) ;
$date2 = date ( 'Y-m-d H:i:s' , $date2 );
break;
case "2H":
$date2 = strtotime ( '-2 hour' , strtotime ( $date ) ) ;
$date2 = date ( 'Y-m-d H:i:s' , $date2 );
break;
case "1H":
$date2 = strtotime ( '-1 hour' , strtotime ( $date ) ) ;
$date2 = date ( 'Y-m-d H:i:s' , $date2 );
break;
case "30M":
$date2 = strtotime ( '-30 minute' , strtotime ( $date ) ) ;
$date2 = date ( 'Y-m-d H:i:s' , $date2 );
break;
case "15M":
$date2 = strtotime ( '-15 minute' , strtotime ( $date ) ) ;
$date2 = date ( 'Y-m-d H:i:s' , $date2 );
break;
case "10M":
$date2 = strtotime ( '-10 minute' , strtotime ( $date ) ) ;
$date2 = date ( 'Y-m-d H:i:s' , $date2 );
break;
case "5M":
$date2 = strtotime ( '-5 minute' , strtotime ( $date ) ) ;
$date2 = date ( 'Y-m-d H:i:s' , $date2 );
break;
case "":
exit();
}
$qry = "SELECT * FROM `summaries` WHERE MarketName = '$MarketName' AND date <= '$date2' ORDER BY id DESC LIMIT 1";
$run = mysqli_query($conexion, $qry) or die(mysqli_error($conexion));
$result = mysqli_fetch_assoc($run);
$precio_Armame = number_format($result['Last'], 8, '.', ' ');
$volumen_Armame = $result['Volumen'];
$thread_id = mysqli_thread_id($conexion);
mysqli_kill($conexion, $thread_id);
mysqli_free_result($run);
mysqli_close($conexion);
return array($precio_Armame, $volumen_Armame);
}
I call this function from another file: (index3.php) This "while" can be more than 200 rows...
.
.
.
$qry = "SELECT `MarketName` FROM `summaries` WHERE `MarketName` LIKE 'BTC%' GROUP BY MarketName HAVING COUNT(*) > 1";
$run = mysqli_query($conexion, $qry) or die("Error: ". mysqli_error($conexion));
$result2 = mysqli_fetch_assoc($run);
mysqli_close($conexion);
$i=0;
if($result2){
while ($result = mysqli_fetch_assoc($run)){
#24H
###################################################################################################################################
list($precio24H, $volumen24H) = armame($date, $result['MarketName'], '24H');
.
.
.
I always receive the message: Warning: mysqli_connect(): (HY000/1203): User jpsoft_desa already has more than 'max_user_connections' active connections in /home/jpsoft/public_html/php/funciones.php on line 25 Error de conexion2: User jpsoft_desa already has more than 'max_user_connections' active connections. But, look, in my function I always close the connections, kills the thread and free the result.... What It's wrong?