Re: [PHP-DB] Simple MySQL sample code runs out of memory

2011-10-28 Thread tamouse mailing lists
On Thu, Oct 27, 2011 at 10:04 PM, wrote: > Something more fundamental is going on. > > Here is simpler code which still reproduces the problem. > I get: > > PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to > allocate 20 bytes) in xx3.php on line 26 > > What's up with

Re: [PHP-DB] Simple MySQL sample code runs out of memory

2011-10-27 Thread Karl DeSaulniers
Also, I don't know how your displaying this info, but if you have a good number of entries, you may want to look into pagination. Then your only grabbing a certain number of sets at a time not the whole database. Best, Karl On Oct 28, 2011, at 12:29 AM, Karl DeSaulniers wrote: Hmmm.. Try th

Re: [PHP-DB] Simple MySQL sample code runs out of memory

2011-10-27 Thread Karl DeSaulniers
Here is a link for researching. http://php.net/manual/en/function.mysql-fetch-assoc.php HTH, Best, Karl On Oct 28, 2011, at 12:35 AM, Karl DeSaulniers wrote: Also, I don't know how your displaying this info, but if you have a good number of entries, you may want to look into pagination. Then

Re: [PHP-DB] Simple MySQL sample code runs out of memory

2011-10-27 Thread Karl DeSaulniers
Hmmm.. Try this.. for($i=0; $i<$num_rows; $i++){ $c = mysql_result($result,$i,"contract"); echo sprintf( "|%13d |%7d |\n", $c, $i ); mysql_free_result($c); //Free the memory with this. } or this.. for($i=0; $i<$num_rows; $i++){ $c = mysql_result($result,$i,"contrac

Re: [PHP-DB] Simple MySQL sample code runs out of memory

2011-10-27 Thread php
On Thu, Oct 27, 2011 at 10:43:48PM -0500, Karl DeSaulniers wrote: > Maybe this.. > HTH, > > ... > > $result = mysql_query( $qry, $db_conn ) or die( mysql_error() . "\n" ); > > $num_rows = mysql_numrows($result); > if(!$result || ($num_rows <= 0)){ > echo "Error displaying info"; > } > else

Re: [PHP-DB] Simple MySQL sample code runs out of memory

2011-10-27 Thread Karl DeSaulniers
Maybe this.. HTH, 0){ for($i=0; $i<$num_rows; $i++){ $c = mysql_result($result,$i,"contract"); echo sprintf( "|%13d |%7d |\n", $c, $i ); } } ?> Best, Karl On Oct 27, 2011, at 6:59 PM, p...@umpquanet.com wrote: Karl DeSaulniers Design Drumm http://designdrumm.com --

Re: [PHP-DB] Simple MySQL sample code runs out of memory

2011-10-27 Thread php
On Thu, Oct 27, 2011 at 09:50:14PM -0500, tamouse mailing lists wrote: > > Still, an inner and outer loop don't really seem necessary here, as > you're spinning through one set of data, there doesn't seem a need to > run through it that way. A more traditional method is to do something > like: >

Re: [PHP-DB] Simple MySQL sample code runs out of memory

2011-10-27 Thread tamouse mailing lists
On Thu, Oct 27, 2011 at 9:36 PM, wrote: > On Thu, Oct 27, 2011 at 09:17:21PM -0500, tamouse mailing lists wrote: >> >> That said, I think there must be a way to do this in SQL. > > Absolutely, there's a way to do this in SQL; > > "select contract, sum(1) from test_table group by contract" > > > B

Re: [PHP-DB] Simple MySQL sample code runs out of memory

2011-10-27 Thread php
On Thu, Oct 27, 2011 at 09:17:21PM -0500, tamouse mailing lists wrote: > > That said, I think there must be a way to do this in SQL. Absolutely, there's a way to do this in SQL; "select contract, sum(1) from test_table group by contract" But as I said, simply counting is not the intent of the

Re: [PHP-DB] Simple MySQL sample code runs out of memory

2011-10-27 Thread Karl DeSaulniers
That and maybe look into mysql_free_result() or mysql_freeresult() Best, Karl Sent from losPhone On Oct 27, 2011, at 9:08 PM, "Toby Hart Dyke" wrote: > > > -Original Message- > From: p...@umpquanet.com [mailto:p...@umpquanet.com] > Sent: Thursday, October 27, 2011 8:00 PM > To: php-

Re: [PHP-DB] Simple MySQL sample code runs out of memory

2011-10-27 Thread tamouse mailing lists
On Thu, Oct 27, 2011 at 8:56 PM, tamouse mailing lists wrote: > On Thu, Oct 27, 2011 at 6:59 PM,   wrote: >> Running PHP 5.3.5 on FreeBSD 8.2 connecting to a MySQL 5.1.55 >> server. >> >> Why does this code (below) run out of memory?  It queries >> test_table for all rows, all fields and sorts the

RE: [PHP-DB] Simple MySQL sample code runs out of memory

2011-10-27 Thread Toby Hart Dyke
-Original Message- From: p...@umpquanet.com [mailto:p...@umpquanet.com] Sent: Thursday, October 27, 2011 8:00 PM To: php-db@lists.php.net Subject: [PHP-DB] Simple MySQL sample code runs out of memory Running PHP 5.3.5 on FreeBSD 8.2 connecting to a MySQL 5.1.55 server. $row =

Re: [PHP-DB] Simple MySQL sample code runs out of memory

2011-10-27 Thread tamouse mailing lists
On Thu, Oct 27, 2011 at 6:59 PM, wrote: > Running PHP 5.3.5 on FreeBSD 8.2 connecting to a MySQL 5.1.55 > server. > > Why does this code (below) run out of memory?  It queries > test_table for all rows, all fields and sorts them by the numeric > 'contract' field.  It then iterates through the row