Webmaster Forum


Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #21 (permalink)  
Old 01-12-2009, 07:55 AM
Contributing Member
 
Join Date: 08-16-08
Posts: 451
iTrader: 3 / 100%
so how could i fix this? becouse it seems the number of queries is growing...
__________________
All about situational leadership | Play free online games on 321games.net
 
Reply With Quote
  #22 (permalink)  
Old 01-12-2009, 07:59 AM
Izzmo's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
Show us some code?
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
 
Reply With Quote
  #23 (permalink)  
Old 01-12-2009, 08:52 AM
Contributing Member
 
Join Date: 08-16-08
Posts: 451
iTrader: 3 / 100%
Not sure which part of code to give

Here is the first half of ez_sql_core.php (file from error) :

Code:
<?php /********************************************************************** * Author: Justin Vincent (justin@visunet.ie) * Web...: http://php.justinvincent.com * Name..: ezSQL * Desc..: ezSQL Core module - database abstraction library to make * it very easy to deal with databases. * */ /********************************************************************** * ezSQL Constants */ define('EZSQL_VERSION','2.03'); define('OBJECT','OBJECT',true); define('ARRAY_A','ARRAY_A',true); define('ARRAY_N','ARRAY_N',true); define('EZSQL_CORE_ERROR','ezSQLcore can not be used by itself (it is designed for use by database specific modules).'); /********************************************************************** * Core class containg common functions to manipulate query result * sets once returned */ class ezSQLcore { var $trace = false; // same as $debug_all var $debug_all = false; // same as $trace var $debug_called = false; var $vardump_called = false; var $show_errors = true; var $num_queries = 0; var $last_query = null; var $last_error = null; var $col_info = null; var $captured_errors = array(); var $cache_dir = false; var $cache_queries = false; var $cache_inserts = false; var $use_disk_cache = false; var $cache_timeout = 24; // hours var $log_to_file = false; // create a file in your root pligg folder // named query.log and chmod 755 // == TJH == default now needed for echo of debug function var $debug_echo_is_on = true; /********************************************************************** * Constructor */ function ezSQLcore() { } /********************************************************************** * Connect to DB - over-ridden by specific DB class */ function connect() { die(EZSQL_CORE_ERROR); } /********************************************************************** * Select DB - over-ridden by specific DB class */ function select() { die(EZSQL_CORE_ERROR); } /********************************************************************** * Basic Query - over-ridden by specific DB class */ function query() { die(EZSQL_CORE_ERROR); } /********************************************************************** * Format a string correctly for safe insert - over-ridden by specific * DB class */ function escape() { die(EZSQL_CORE_ERROR); } /********************************************************************** * Return database specific system date syntax * i.e. Oracle: SYSDATE Mysql: NOW() */ function sysdate() { die(EZSQL_CORE_ERROR); } /********************************************************************** * Print SQL/DB error - over-ridden by specific DB class */ function register_error($err_str) { // Keep track of last error $this->last_error = $err_str; // Capture all errors to an error array no matter what happens $this->captured_errors[] = array ( 'error_str' => $err_str, 'query' => $this->last_query ); } /********************************************************************** * Turn error handling on or off.. */ function show_errors() { $this->show_errors = true; } function hide_errors() { $this->show_errors = false; } /********************************************************************** * Kill cached query results */ function flush() { // Get rid of these $this->last_result = null; $this->col_info = null; $this->last_query = null; $this->from_disk_cache = false; } /********************************************************************** * Get one variable from the DB - see docs for more detail */ function get_var($query=null,$x=0,$y=0) { // Log how the function was called $this->func_call = "\$db->get_var(\"$query\",$x,$y)"; // If there is a query then perform it if not then use cached results.. if ( $query ) { $this->query($query); } // Extract var out of cached results based x,y vals if ( $this->last_result[$y] ) { $values = array_values(get_object_vars($this->last_result[$y])); } // If there is a value return it else return null return (isset($values[$x]) && $values[$x]!=='')?$values[$x]:null; } /********************************************************************** * Get one row from the DB - see docs for more detail */ function get_row($query=null,$output=OBJECT,$y=0) { // Log how the function was called $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; // If there is a query then perform it if not then use cached results.. if ( $query ) { $this->query($query); } // If the output is an object then return object using the row offset.. if ( $output == OBJECT ) { return $this->last_result[$y]?$this->last_result[$y]:null; } // If the output is an associative array then return row as such.. elseif ( $output == ARRAY_A ) { return $this->last_result[$y]?get_object_vars($this->last_result[$y]):null; } // If the output is an numerical array then return row as such.. elseif ( $output == ARRAY_N ) { return $this->last_result[$y]?array_values(get_object_vars($this->last_result[$y])):null; } // If invalid output type was specified.. else { $this->print_error(" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N"); } } /********************************************************************** * Function to get 1 column from the cached result set based in X index * see docs for usage and info */ function get_col($query=null,$x=0) { // If there is a query then perform it if not then use cached results.. if ( $query ) { $this->query($query); } // Extract the column values for ( $i=0; $i < count($this->last_result); $i++ ) { $new_array[$i] = $this->get_var(null,$x,$i); } if(!isset($new_array)){$new_array = array();} return $new_array; } /********************************************************************** * Return the the query as a result set - see docs for more details */ function get_results($query=null, $output = OBJECT) { // Log how the function was called $this->func_call = "\$db->get_results(\"$query\", $output)"; // If there is a query then perform it if not then use cached results.. if ( $query ) { $this->query($query); } // Send back array of objects. Each row is an object if ( $output == OBJECT ) { return $this->last_result; } elseif ( $output == ARRAY_A || $output == ARRAY_N ) { if ( $this->last_result ) { $i=0; foreach( $this->last_result as $row ) { $new_array[$i] = get_object_vars($row); if ( $output == ARRAY_N ) { $new_array[$i] = array_values($new_array[$i]); } $i++; } return $new_array; } else { return null; } } } /********************************************************************** * Function to get column meta data info pertaining to the last query * see docs for more info and usage */ function get_col_info($info_type="name",$col_offset=-1) { if ( $this->col_info ) { if ( $col_offset == -1 ) { $i=0; foreach($this->col_info as $col ) { $new_array[$i] = $col->{$info_type}; $i++; } return $new_array; } else { return $this->col_info[$col_offset]->{$info_type}; } } } /********************************************************************** * store_cache */ function store_cache($query,$is_insert) { // The would be cache file for this query $cache_file = $this->cache_dir.'/'.md5($query); // disk caching of queries if ( $this->use_disk_cache && ( $this->cache_queries && ! $is_insert ) || ( $this->cache_inserts && $is_insert )) { if ( ! is_dir($this->cache_dir) ) { $this->register_error("Could not open cache dir: $this->cache_dir"); $this->show_errors ? trigger_error("Could not open cache dir: $this->cache_dir",E_USER_WARNING) : null; } else { // Cache all result values $result_cache = array ( 'col_info' => $this->col_info, 'last_result' => $this->last_result, 'num_rows' => $this->num_rows, 'return_value' => $this->num_rows, ); error_log ( serialize($result_cache), 3, $cache_file); } } } /********************************************************************** * get_cache */ function get_cache($query) { // The would be cache file for this query $cache_file = $this->cache_dir.'/'.md5($query); // Try to get previously cached version if ( $this->use_disk_cache && $this->cache_queries && file_exists($cache_file) ) { // Only use this cache file if less than 'cache_timeout' (hours) if ( (time() - filemtime($cache_file)) > ($this->cache_timeout*3600) ) { unlink($cache_file); } else { $result_cache = unserialize(file_get_contents($cache_file)); $this->col_info = $result_cache['col_info']; $this->last_result = $result_cache['last_result']; $this->num_rows = $result_cache['num_rows']; $this->from_disk_cache = true; // If debug ALL queries $this->trace || $this->debug_all ? $this->debug() : null ; return $result_cache['return_value']; } } } /********************************************************************** * Dumps the contents of any input variable to screen in a nicely * formatted and easy to understand way - any type: Object, Var or Array */ function vardump($mixed='') { // Start outup buffering ob_start(); echo "<p><table><tr><td bgcolor=ffffff><blockquote><font color=000090>"; echo "<pre><font face=arial>"; if ( ! $this->vardump_called ) { echo "<font color=800080><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Variable Dump..</b></font>\n\n"; } $var_type = gettype ($mixed); print_r(($mixed?$mixed:"<font color=red>No Value / False</font>")); echo "\n\n<b>Type:</b> " . ucfirst($var_type) . "\n"; echo "<b>Last Query</b> [$this->num_queries]<b>:</b> ".($this->last_query?$this->last_query:"NULL")."\n"; echo "<b>Last Function Call:</b> " . ($this->func_call?$this->func_call:"None")."\n"; echo "<b>Last Rows Returned:</b> ".count($this->last_result)."\n"; echo "</font></pre></font></blockquote></td></tr></table>".$this->donation(); echo "\n<hr size=1 noshade color=dddddd>"; // Stop output buffering and capture debug HTML $html = ob_get_contents(); ob_end_clean(); // Only echo output if it is turned on if ( $this->debug_echo_is_on ) { echo $html; } $this->vardump_called = true; return $html; } /********************************************************************** * Alias for the above function */ function dumpvar($mixed) { $this->vardump($mixed); } /********************************************************************** * Displays the last query string that was sent to the database & a * table listing results (if there were any). * (abstracted into a seperate file to save server overhead). */ function debug() { // Start outup buffering ob_start(); echo "<blockquote>"; // Only show ezSQL credits once.. if ( ! $this->debug_called ) { echo "<font color=800080 face=arial size=2><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Debug..</b></font><p>\n"; } if ( $this->last_error ) { echo "<font face=arial size=2 color=000099><b>Last Error --</b> [<font color=000000><b>$this->last_error</b></font>]<p>"; } if ( $this->from_disk_cache ) { echo "<font face=arial size=2 color=000099><b>Results retrieved from disk cache</b></font><p>"; } echo "<font face=arial size=2 color=000099><b>Query</b> [$this->num_queries] <b>--</b> "; echo "[<font color=000000><b>$this->last_query</b></font>]</font><p>"; echo "<font face=arial size=2 color=000099><b>Query Result..</b></font>"; echo "<blockquote>"; if ( $this->col_info ) { // ===================================================== // Results top rows echo "<table cellpadding=5 cellspacing=1 bgcolor=555555>"; echo "<tr bgcolor=eeeeee><td nowrap valign=bottom><font color=555599 face=arial size=2><b>(row)</b></font></td>"; for ( $i=0; $i < count($this->col_info); $i++ ) { echo "<td nowrap align=left valign=top><font size=1 color=555599 face=arial>{$this->col_info[$i]->type} {$this->col_info[$i]->max_length}</font><br><span style='font-family: arial; font-size: 10pt; font-weight: bold;'>{$this->col_info[$i]->name}</span></td>"; } echo "</tr>"; // ====================================================== // print main results if ( $this->last_result ) { $i=0; foreach ( $this->get_results(null,ARRAY_N) as $one_row ) { $i++; echo "<tr bgcolor=ffffff><td bgcolor=eeeeee nowrap align=middle><font size=2 color=555599 face=arial>$i</font></td>"; foreach ( $one_row as $item ) { echo "<td nowrap><font face=arial size=2>$item</font></td>"; } echo "</tr>"; }
This is the line 374 (from error):
Code:
$result_cache = unserialize(file_get_contents($cache_file));
Thank you very much for the help
__________________
All about situational leadership | Play free online games on 321games.net
 
Reply With Quote
  #24 (permalink)  
Old 01-12-2009, 08:53 AM
Contributing Member
 
Join Date: 08-16-08
Posts: 451
iTrader: 3 / 100%
and this is the second part of it becouse of the 15.000 letters maximum:

Code:
} // if last result else { echo "<tr bgcolor=ffffff><td colspan=".(count($this->col_info)+1)."><font face=arial size=2>No Results</font></td></tr>"; } echo "</table>"; } // if col_info else { echo "<font face=arial size=2>No Results</font>"; } echo "</blockquote></blockquote>".$this->donation()."<hr noshade color=dddddd size=1>"; // Stop output buffering and capture debug HTML $html = ob_get_contents(); ob_end_clean(); // Only echo output if it is turned on if ( $this->debug_echo_is_on ) { echo $html; } $this->debug_called = true; return $html; } /********************************************************************** * Naughty little function to ask for some remuniration! */ function donation() { return "<font size=1 face=arial color=000000>If ezSQL has helped <a href=\"https://www.paypal.com/xclick/business=justin%40justinvincent.com&item_name=ezSQL&no_note=1&tax=0\" style=\"color: 0000CC;\">make a donation!?</a> &nbsp;&nbsp;<!--[ go on! you know you want to! ]--></font>"; } } ?>
__________________
All about situational leadership | Play free online games on 321games.net
 
Reply With Quote
  #25 (permalink)  
Old 01-12-2009, 09:59 AM
Izzmo's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
Alright, well that's explains it. It's trying to do I/O functions.

How big is the file being read, do you know?
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
 
Reply With Quote
  #26 (permalink)  
Old 01-12-2009, 11:18 AM
Contributing Member
 
Join Date: 08-16-08
Posts: 451
iTrader: 3 / 100%
i am not sure

which file are we talking about ?
__________________
All about situational leadership | Play free online games on 321games.net
 
Reply With Quote
  #27 (permalink)  
Old 01-12-2009, 11:37 AM
Izzmo's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
I see what it's doing.

Okay, here's your problem:

It's trying to cache the results of your SQL queries to a file on the server. What's happening is PHP is not allowed to write the file to the disc because the amount of data pulled back from the database exceeds the amount of memory allocated to your account. Probably 2M? So, when it pulls the data out of the database, it has to put it somewhere, so it puts it in the memory (which gets released at the end of the script execution), but it's not able to since it exceeds the allotted amount.

So, either you will have to disable caching on your site or get your host to provide you with more memory.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
 
Reply With Quote
  #28 (permalink)  
Old 01-12-2009, 12:59 PM
ScriptMan's Avatar
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 10,257
iTrader: 4 / 100%
Doesn't sound like a friendly script for a shared hosting account.

I had a resource pig like that running on local once. Brought my system to a stanstill.
__________________
SEO does not mean Spam Everywhere Online
Scriptman's Playhouse || Ramblings from an old man
2013 resolution: Don't feed trolls
ScriptMan
 
Reply With Quote
  #29 (permalink)  
Old 01-12-2009, 01:08 PM
Contributing Member
 
Join Date: 08-16-08
Posts: 451
iTrader: 3 / 100%
so i should forget about that site and just delite it? or is there any simple way to disable caching?
__________________
All about situational leadership | Play free online games on 321games.net
 
Reply With Quote
  #30 (permalink)  
Old 01-12-2009, 01:11 PM
Izzmo's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
There is not an option in the settings for it?
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
 
Reply With Quote
  #31 (permalink)  
Old 01-13-2009, 09:24 AM
Contributing Member
 
Join Date: 08-16-08
Posts: 451
iTrader: 3 / 100%
i don't think so...

i cannot even access the site lol looks like it's constantly "taking too much memory"
__________________
All about situational leadership | Play free online games on 321games.net
 
Reply With Quote
  #32 (permalink)  
Old 01-13-2009, 01:57 PM
Izzmo's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
Well that's not good. You might want to look for a different solutions then, or find something in your code to limit the amount of results it pulls back.

(Or, if it doesn't matter, delete some information out of your database)
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
 
Reply With Quote
  #33 (permalink)  
Old 01-13-2009, 02:29 PM
Junior Member
 
Join Date: 01-05-09
Location: netherlands
Posts: 20
iTrader: 0 / 0%
one option is checking who 'owns' the cache, making sure it is on 777, and meanwhile erasing all files that are cached. Once the script can write a new cache it might be fine ?
 
Reply With Quote
  #34 (permalink)  
Old 01-13-2009, 02:45 PM
Izzmo's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
That doesn't matter. Most webhosts make their accounts run under the users account nowadays anyway.. not the system (root).
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
 
Reply With Quote
  #35 (permalink)  
Old 01-13-2009, 04:40 PM
ScriptMan's Avatar
Super Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 10,257
iTrader: 4 / 100%
I read a post in another forum last night regarding this script. It looks like you need a decent VPS or above to get it to work.

I think they called in "extremely" database intensive.
__________________
SEO does not mean Spam Everywhere Online
Scriptman's Playhouse || Ramblings from an old man
2013 resolution: Don't feed trolls
ScriptMan
 
Reply With Quote
  #36 (permalink)  
Old 01-13-2009, 07:45 PM
Izzmo's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
Thanks ScriptMan! Looks like our assumptions were right then.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
 
Reply With Quote
  #37 (permalink)  
Old 01-14-2009, 11:38 PM
Contributing Member
 
Join Date: 08-16-08
Posts: 451
iTrader: 3 / 100%
ok so i'm deliting that site

is there any better diggclone script?

i've google it, and found many of them, but i do not know which one is very good written

can you please give me some sugestions?
__________________
All about situational leadership | Play free online games on 321games.net
 
Reply With Quote
  #38 (permalink)  
Old 01-15-2009, 07:49 AM
Contributing Member
 
Join Date: 08-16-08
Posts: 451
iTrader: 3 / 100%
page started working out of sudden what's going on? i did not do anything, what could have happened?
__________________
All about situational leadership | Play free online games on 321games.net
 
Reply With Quote
  #39 (permalink)  
Old 01-15-2009, 08:40 AM
Izzmo's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 11-01-03
Location: Kansas
Posts: 1,356
iTrader: 1 / 100%
It could be something with the cache files themselves. They were too big to read, but since the cache expired, it deleted and recreated them, and in doing so, the new cache file may be smaller.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Feed - Fatal error: Call to a member function children() on a non-object jagan Coding Forum 2 08-25-2008 02:22 PM
OpenVZ Error : Cannot allocate memory eukvps Dedicated Servers 0 06-22-2007 01:39 AM
"Method POST not allowed" error east_pole Web Design Lobby 3 02-16-2007 01:57 PM
phpBB - Fatal Error Allowed memory size exhausted Fruit & Veg Coding Forum 3 09-18-2004 12:55 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 10:46 AM.
Powered by vBulletin
Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.