Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev
Reply
  #1  
Old 1st June 2021, 23:39
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 171
Default 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
Reply With Quote
  #2  
Old 2nd June 2021, 06:18
Elena's Avatar
Elena Elena is offline
Senior Member
 
Join Date: Sep 2010
P2P
Posts: 74
Default
you have a wrong query in the userdetails and not in the sql error function.
Show the request in userdetails line 240.
Reply With Quote
  #3  
Old 2nd June 2021, 06:41
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 171
Default
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]";

}

Last edited by elvira; 2nd June 2021 at 07:00.
Reply With Quote
  #4  
Old 2nd June 2021, 13:01
rio's Avatar
rio rio is offline
Senior Member
 
Join Date: May 2019
P2P
Posts: 54
Default
Add this to the top of the file ini_set('memory_limit','-1'); or edit it in php.ini
__________________
Live Free... Share Free...
Reply With Quote
  #5  
Old 2nd June 2021, 15:13
DND's Avatar
DND DND is offline
VIP
 
Join Date: Dec 2008
Posts: 1,144
Default
just increase your memory_limit
__________________
Need HELP!? I can install:

  1. Server/VPS (Debian,CentOS,Ubuntu,Fedora, FreeBSD) Optimization and ... + Modules
  2. Webserver Windows/Linux (Apache/Lighttpd/Nginx/Mysql/PhpMyAdmin/SSL) Optimization and ... + Modules
  3. Seedbox Windows/Linux (uTorrent,rTorrent,libTorrent,ruTorrent) + Modules
  4. TBDev Support
  5. Gazelle Support Install
  6. TSSE Install Support
Reply With Quote
  #6  
Old 2nd June 2021, 15:21
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 171
Default
ok, where can find memory_limit in php.ini
Reply With Quote
  #7  
Old 2nd June 2021, 20:48
Elena's Avatar
Elena Elena is offline
Senior Member
 
Join Date: Sep 2010
P2P
Posts: 74
Thumbs up
Quote:
Originally Posted by elvira View Post
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]";}
Reply With Quote
  #8  
Old 3rd June 2021, 11:39
szaby's Avatar
szaby szaby is offline
Senior Member
 
Join Date: Jul 2008
Posts: 19
Default
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(["<",">",'"',"'",], ["&lt;","&gt;","&quot;",''',], $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(id) FROM comments WHERE user = ".(int)$user['id']) OR sqlerr(__FILE__,__LINE__) );
$torrentcomments $arrcom[0];

$arrposts mysqli_fetch_row sql_query("SELECT COUNT(id) FROM 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.
Reply With Quote
  #9  
Old 3rd June 2021, 12:12
Elena's Avatar
Elena Elena is offline
Senior Member
 
Join Date: Sep 2010
P2P
Posts: 74
Default
Code:
if(!function_exists("htmlspecialchars_uni")){function htmlspecialchars_uni($message){
$message = preg_replace("#&(?!\#[0-9]+;)#si", "&amp;", $message); // Fix & but allow unicode
$message = str_replace("<","&lt;",$message);$message = str_replace(">","&gt;",$message);
$message = str_replace("\"","&quot;",$message);$message = str_replace("  ", "&nbsp;&nbsp;", $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?
Reply With Quote
  #10  
Old 3rd June 2021, 21:53
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 171
Default
i still don't know what to do
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 10:15. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2021, vBulletin Solutions Inc.