Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   TBDev (http://www.bvlist.com/forumdisplay.php?f=20)
-   -   SQL ERROR (http://www.bvlist.com/showthread.php?t=12370)

elvira 1st June 2021 23:39

SQL ERROR
 
Hey all,


can you help me please


Got this error


SQL ERROR
MySQL server has gone awayin /home/admin/web/include/functions.php, line 157


line is in fuctions.php


Code:

function write_log($text)
{
  $text = sqlesc($text);
  $added = sqlesc(get_date_time());
  mysqli_query($GLOBALS["___mysqli_ston"], "INSERT INTO sitelog (added, txt) VALUES($added, $text)") or sqlerr(__FILE__, __LINE__);
}

and ErrorLog say

Code:

PHP Warning:  Error while sending QUERY packet. PID=23744 in /home/admin/web/public_html/userdetails.php on line 240
Code:

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 130968 bytes) in /home/admin/web/public_html/include/functions.php on line 154

Elena 2nd June 2021 06:18

you have a wrong query in the userdetails and not in the sql error function.
Show the request in userdetails line 240.

elvira 2nd June 2021 06:41

However, it is interesting that it does not show me an error in all users only for some


Quote:

$res = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT COUNT(*) FROM comments WHERE user = {$user['id']}") or sqlerr(__FILE__,__LINE__);
$arr3 = mysqli_fetch_row($res);
$torrentcomments = $arr3[0];
$res = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT COUNT(*) FROM posts WHERE userid = {$user['id']}") or sqlerr(__FILE__,__LINE__);
$arr3 = mysqli_fetch_row($res);
$forumposts = $arr3[0];

$res = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT name FROM clientselect WHERE id = {$user['clientselect']} LIMIT 1") or sqlerr(__FILE__,__LINE__);

if (mysqli_num_rows($res) == 1)

{

$arr = mysqli_fetch_array($res);

$clientselect = "$arr[name]";

}

rio 2nd June 2021 13:01

Add this to the top of the file ini_set('memory_limit','-1'); or edit it in php.ini

DND 2nd June 2021 15:13

just increase your memory_limit

elvira 2nd June 2021 15:21

ok, where can find memory_limit in php.ini

Elena 2nd June 2021 20:48

Quote:

Originally Posted by elvira (Post 55549)
However, it is interesting that it does not show me an error in all users only for some

Code:

$rescom = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT COUNT(*) FROM comments WHERE user = ".$user['id']) or sqlerr(__FILE__,__LINE__);
$arrcom  = mysqli_fetch_row($rescom );
$torrentcomments = $arrcom[0];

$resposts = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT COUNT(*) FROM posts WHERE userid = ".$user['id']) or sqlerr(__FILE__,__LINE__);
$arrposts = mysqli_fetch_row($resposts);
$forumposts = $arrposts[0];

$resclient = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT name FROM clientselect WHERE id = ".$user['clientselect']." LIMIT 1") or sqlerr(__FILE__,__LINE__);
$row = mysqli_fetch_array($resclient);if($row){$clientselect = "$row[name]";}

on the last request it is not clear what you specifically want.
For the first two - you can not mix the names of variables, you will sometimes get out errors.

Or so you can:
Code:

$resclient = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT name FROM clientselect WHERE id = ".$user['clientselect']) or sqlerr(__FILE__,__LINE__);
$row = mysqli_fetch_array($resclient);if($row){$clientselect = "$row[name]";}

:coffee:

szaby 3rd June 2021 11:39

Hello!

PHP Code:

function sql_query($query) {
  
$result mysqli_query($GLOBALS["___mysqli_ston"], $query);
}

function 
htmlsafechars($txt '') {
  
$txt preg_replace("/&(?!#[0-9]+;)(?:amp;)?/s"'&'$txt);
  
$txt str_replace(["<",">",'"',"'",], ["<",">",""",''',], $txt);
  return 
$txt;
}

function sqlesc(
$x) {
  if (is_integer(
$x)) {
    return (int) 
$x;
  } elseif (is_float(
$x)) {
    return (float) 
$x;
  }
  return sprintf('\'%s\'', ((isset(
$GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"]$x) : ((trigger_error("Err", E_USER_ERROR)) ? "" : "")));
}


$arrcom = mysqli_fetch_row ( sql_query("SELECT COUNT(idFROM comments WHERE user ".(int)$user['id']) OR sqlerr(__FILE__,__LINE__) );
$torrentcomments = $arrcom[0];

$arrposts = mysqli_fetch_row ( sql_query("SELECT COUNT(idFROM posts WHERE userid ".(int)$user['id']) OR sqlerr(__FILE__,__LINE__) );
$forumposts = $arrposts[0];

$row = mysqli_fetch_array ( sql_query("SELECT name FROM clientselect WHERE id ".sqlesc($user['clientselect'])." LIMIT 1") OR sqlerr(__FILE__,__LINE__) );
if (
$row) {
  
$clientselect = htmlsafechars($row["name"]);


Why are you complicating too much? Use functions more and it will be much better and more beautiful.This is just my opinion.

Elena 3rd June 2021 12:12

Code:

if(!function_exists("htmlspecialchars_uni")){function htmlspecialchars_uni($message){
$message = preg_replace("#&(?!\#[0-9]+;)#si", "&", $message); // Fix & but allow unicode
$message = str_replace("<","<",$message);$message = str_replace(">",">",$message);
$message = str_replace("\"",""",$message);$message = str_replace("  ", "  ", $message);return $message;}
////////////////////////////////
function html_uni($str){return htmlspecialchars_uni($str);}}

In general, I'm wildly interested - why two requests for the number of Comments and Posts? I have it all ALREADY in the table USERS, for EVERY user. And the statistics of the USER on my CACHE file in the version FastCGI (Nginx + PHP-FPM) PHP 5.4.45 and for FastCGI (Nginx + PHP-FPM) PHP 8.0.3 I use MEMKESH.
I would have someone to take a picture - why the hell do I need to find out the client's name?

elvira 3rd June 2021 21:53

i still don't know what to do


All times are GMT +2. The time now is 00:57.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2022, vBulletin Solutions Inc.