Re: [PHP] Issue of upgrading from to 5.x

2009-09-28 Thread Lars Torben Wilson

Chris Streatfield wrote:

Here's a little problem I'm just discovering.

The issue has been brought to my attention by a couple of my clients when 
their mail() replies were suddenly turning up with zero variable content. 

I have several html/php contact/subscribe forms which return a mail reply to 
the web site owner. These have recently been turning up with none of the 
variables being picked up from the html form. The mail() library is still 
sending the reply correctly. All the material is hosted on commercial ISP web 
servers. A couple of them have clearly upgraded to PHP 5.x recently.


When a user fills out the form and presses the submit button the process page 
picks up the variables from the input and mails the output back to the site 
owner. Recently some of these replies have started to show up with the 
variables not being picked up. On looking through the official PHP 
documentation it would seem to be an issue of the change in the use of 
globals being turned off by default in 5.x onwards. I found an example of a 
function in the documentation to include that simulates globals being turned 
on but this does not seem to be working as expected.


Hi Chris,

Don't worry; globals have not been disabled. However, what you're 
referring to (registering input data as global variables) has been 
disabled by default since PHP 4.2. It has always been possible to 
disable it (and for a long time, recommended to disable it) via the 
register_globals ini directive, and it's still possible to enable it 
using register_globals.


However: like I said, it's not recommended. It's a security risk, and 
registering input data as global variables will be removed entirely in 
PHP 6. As of PHP 5.3 it is officially deprecated.


Have a look at the following page in the documentation for more 
information on this:


  http://www.php.net/manual/en/ini.core.php#ini.register-globals

In a case like yours, I'd recommend leaving register_globals disabled 
and either fixing your scripts, or prepending an included file which 
would gather the needed data from $_GET, $_POST, or $_REQUEST, sanitize 
it, and *then* create the needed global variables using that data. This 
second option would likely require the fewest changes to your existing 
scripts.



Regards,

Torben

While this is a very simple (and possibly only a bit irritating) problem the 
nightmare scenario for me is that I have a great many files (read several Ks) 
that rely on the same functionality, as the access to several MySql 
databases. I have very quickly tested a couple of these database constructs 
on one of the hosting sites where the mail() forms have failed and the 
database constructs do not work either. I really would prefer not to have to 
spend the whole of the next year re-writing all these files especially as 
this work is all voluntary.


Now if these very simple html form / php processing structures are now going 
to fail by not retrieving the variables what are we supposed to do to create 
web site contact forms or data entry pages for database access. I have tried 
constructing the forms as hybrid php/html and included the function noted 
above and this did not work either. In fact on one of the servers running the 
upgrade even logging on to the database construct froze at the first 
processing page. I think that either this 

header("Location: adminhome.php");
exit();  failed to trigger or the "session_register();" failed.raised

Any suggestions advice would be most welcome.

I have included an example snippet of code from one of the mailback forms that 
has been working correctly for several years.


A snippet of example code
The Form:
Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

http://www.w3.org/1999/xhtml";>


On-line Membership form



Join the Campaign
ON-LINE ANNUAL SUBSCRIPTION FORM

Contact Details

Name
size="35" />

Address

Suburb

City/Postcode

Phone
..



-ENDS---
The processing done in -
$mailcontent="This is the reply from the on-line membership subscription form 
on the web-site.

Contact Details-\n
Name:- $firstname
Address:--
$address
$suburb
$city\n
Phone:--- $tel
...
--";
$additionalheaders="From: webs...@example.com\n";
mail($toaddress, $subject, $mailcontent, $additionalheaders);
?>
---ENDS

All the best
Chris





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Text similarity

2009-09-28 Thread Merlin Morgenstern

Hi there,

I am trying to find out similarity between 2 strings. Somehow the 
similar_text function returns 33% similarity on strings that are not 
even close and on the other hand it returns 21% on strings that have a 
matching word.


E.G:

'gemütliche sofas'

Wohngemeinschaften - similarity: 33.
Sofas & Sessel - similarity: 31.25

I am using this code:
similar_text($data[txt], $categories[$i], $similarity);

Does anybody have an idea why it gives back 33% similarity on the first 
string?


Thank you for any help,

Merlin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Text similarity

2009-09-28 Thread Ashley Sheridan
On Mon, 2009-09-28 at 12:27 +0200, Merlin Morgenstern wrote:
> Hi there,
> 
> I am trying to find out similarity between 2 strings. Somehow the 
> similar_text function returns 33% similarity on strings that are not 
> even close and on the other hand it returns 21% on strings that have a 
> matching word.
> 
> E.G:
> 
> 'gemütliche sofas'
> 
> Wohngemeinschaften - similarity: 33.
> Sofas & Sessel - similarity: 31.25
> 
> I am using this code:
> similar_text($data[txt], $categories[$i], $similarity);
> 
> Does anybody have an idea why it gives back 33% similarity on the first 
> string?
> 
> Thank you for any help,
> 
> Merlin
> 

If you think about it, it makes sense.

Taking your three sentences above, 'Wohngemeinschaften' has more
characters similar towards the start of the string (you only have to go
4 characters in to start a match) whereas 'sofas' won't match the source
string until the 12th string in. Also, both test strings have the same
number of characters that match in order, although the ones that match
in 'Wohngemeinschaften' are separated by characters that do not match,
so I'm not sure what bearing this will have.

As noted on the manual page for this function, the similar_text()
function compares without regard to string length, and tends to only
really be accurate enough for larger excerpts of text.

Thanks,
Ash
http://www.ashleysheridan.co.uk




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Bad impact of memory_limit set to -1 ?

2009-09-28 Thread Manuel Vacelet
On Fri, Sep 25, 2009 at 2:18 PM, Manuel Vacelet
 wrote:
> Hi all,
>
> I fighting with SoapServer to be able to upload large file base64 encoded.
> Every so often I get memory exhausted error messages and
> memory_get_usage() tells me that my script starts with more than 250MB
> allocated (for a soap request of 85MB!).
>
> I'm wondering if I would let memory_limit unbound (-1) to avoid those
> issues but I don't know what would be the consequences (esp. on
> apaches processes, total allocated memory, etc).
>
> Any advice ?
> Thanks,
> Manuel

Hi,

I've read somewhere that increasing memory_limit can affect server's
ability to handle concurrency.
Is it urban legends or is it correct ?
And if it's correct, what about setting it to -1 ?

Manuel

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Text similarity

2009-09-28 Thread Merlin Morgenstern



Ashley Sheridan wrote:

On Mon, 2009-09-28 at 12:27 +0200, Merlin Morgenstern wrote:

Hi there,

I am trying to find out similarity between 2 strings. Somehow the 
similar_text function returns 33% similarity on strings that are not 
even close and on the other hand it returns 21% on strings that have a 
matching word.


E.G:

'gemütliche sofas'

Wohngemeinschaften - similarity: 33.
Sofas & Sessel - similarity: 31.25

I am using this code:
similar_text($data[txt], $categories[$i], $similarity);

Does anybody have an idea why it gives back 33% similarity on the first 
string?


Thank you for any help,

Merlin



If you think about it, it makes sense.

Taking your three sentences above, 'Wohngemeinschaften' has more
characters similar towards the start of the string (you only have to go
4 characters in to start a match) whereas 'sofas' won't match the source
string until the 12th string in. Also, both test strings have the same
number of characters that match in order, although the ones that match
in 'Wohngemeinschaften' are separated by characters that do not match,
so I'm not sure what bearing this will have.

As noted on the manual page for this function, the similar_text()
function compares without regard to string length, and tends to only
really be accurate enough for larger excerpts of text.

Thanks,
Ash
http://www.ashleysheridan.co.uk





Sounds logical. Is there another function you suggest? I guess this is a 
standard problem I am having here. I tried it with levenstein, but 
similar results.


e.g levenstein (smaller = better):
Search for : Stellplatz für Wohnwagen gesucht
Stereoanlagen : 23
Wohnwagen, -mobile : 24
Sonstiges für Baby & Kind - : 25
Steuer & Finanzen - :25

How come stereoanlagen and the others shows up here?

Any idea how I could make this more accurate?

Thank you for any help, Merlin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Text similarity

2009-09-28 Thread Ashley Sheridan
On Mon, 2009-09-28 at 13:07 +0200, Merlin Morgenstern wrote:
> 
> Ashley Sheridan wrote:
> > On Mon, 2009-09-28 at 12:27 +0200, Merlin Morgenstern wrote:
> >> Hi there,
> >>
> >> I am trying to find out similarity between 2 strings. Somehow the 
> >> similar_text function returns 33% similarity on strings that are not 
> >> even close and on the other hand it returns 21% on strings that have a 
> >> matching word.
> >>
> >> E.G:
> >>
> >> 'gemütliche sofas'
> >>
> >> Wohngemeinschaften - similarity: 33.
> >> Sofas & Sessel - similarity: 31.25
> >>
> >> I am using this code:
> >> similar_text($data[txt], $categories[$i], $similarity);
> >>
> >> Does anybody have an idea why it gives back 33% similarity on the first 
> >> string?
> >>
> >> Thank you for any help,
> >>
> >> Merlin
> >>
> > 
> > If you think about it, it makes sense.
> > 
> > Taking your three sentences above, 'Wohngemeinschaften' has more
> > characters similar towards the start of the string (you only have to go
> > 4 characters in to start a match) whereas 'sofas' won't match the source
> > string until the 12th string in. Also, both test strings have the same
> > number of characters that match in order, although the ones that match
> > in 'Wohngemeinschaften' are separated by characters that do not match,
> > so I'm not sure what bearing this will have.
> > 
> > As noted on the manual page for this function, the similar_text()
> > function compares without regard to string length, and tends to only
> > really be accurate enough for larger excerpts of text.
> > 
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> > 
> > 
> > 
> 
> Sounds logical. Is there another function you suggest? I guess this is a 
> standard problem I am having here. I tried it with levenstein, but 
> similar results.
> 
> e.g levenstein (smaller = better):
> Search for : Stellplatz für Wohnwagen gesucht
> Stereoanlagen : 23
> Wohnwagen, -mobile : 24
> Sonstiges für Baby & Kind - : 25
> Steuer & Finanzen - :25
> 
> How come stereoanlagen and the others shows up here?
> 
> Any idea how I could make this more accurate?
> 
> Thank you for any help, Merlin
> 

I'm guessing it's to do with the position of characters within the
string. You could roll your own function, that does what you
specifically need.

Break down the lines into individual words.

Loop through the match string and see if the words exist within the
phrases you're searching in, and keep a count of all 'hits'. As you
loop, create a metaphone key (soundex might also help, but I think
metaphone will work fairly well for German) and check this against a
metaphone version of the phrases you're searching in. Keep a separate
count of metaphone matches.

At the end, any of the search phrases that have either type of count is
a match. Collate them, and order by solid matches (whole words) and then
by metaphone matches.

This is very simplified, and will need a lot of tweaking to get it
right, but it might be somewhere to start?

Thanks,
Ash
http://www.ashleysheridan.co.uk




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Text similarity

2009-09-28 Thread Tom Worster
On 9/28/09 7:07 AM, "Merlin Morgenstern"  wrote:

> 
> 
> Ashley Sheridan wrote:
>> On Mon, 2009-09-28 at 12:27 +0200, Merlin Morgenstern wrote:
>>> Hi there,
>>> 
>>> I am trying to find out similarity between 2 strings. Somehow the
>>> similar_text function returns 33% similarity on strings that are not
>>> even close and on the other hand it returns 21% on strings that have a
>>> matching word.
>>> 
>>> E.G:
>>> 
>>> 'gemütliche sofas'
>>> 
>>> Wohngemeinschaften - similarity: 33.
>>> Sofas & Sessel - similarity: 31.25
>>> 
>>> I am using this code:
>>> similar_text($data[txt], $categories[$i], $similarity);
>>> 
>>> Does anybody have an idea why it gives back 33% similarity on the first
>>> string?
>>> 
>>> Thank you for any help,
>>> 
>>> Merlin
>>> 
>> 
>> If you think about it, it makes sense.
>> 
>> Taking your three sentences above, 'Wohngemeinschaften' has more
>> characters similar towards the start of the string (you only have to go
>> 4 characters in to start a match) whereas 'sofas' won't match the source
>> string until the 12th string in. Also, both test strings have the same
>> number of characters that match in order, although the ones that match
>> in 'Wohngemeinschaften' are separated by characters that do not match,
>> so I'm not sure what bearing this will have.
>> 
>> As noted on the manual page for this function, the similar_text()
>> function compares without regard to string length, and tends to only
>> really be accurate enough for larger excerpts of text.
>> 
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>> 
>> 
>> 
> 
> Sounds logical. Is there another function you suggest? I guess this is a
> standard problem I am having here. I tried it with levenstein, but
> similar results.
> 
> e.g levenstein (smaller = better):
> Search for : Stellplatz fÃ1Ž4r Wohnwagen gesucht
> Stereoanlagen : 23
> Wohnwagen, -mobile : 24
> Sonstiges fÃ1Ž4r Baby & Kind - : 25
> Steuer & Finanzen - :25
> 
> How come stereoanlagen and the others shows up here?
> 
> Any idea how I could make this more accurate?
> 
> Thank you for any help, Merlin

as ashley pointed out, it's not a trivial problem.

if you are performing the tests against strings in a db table then a full
text index might help. see, e.g.:
http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

you could also check out the php sphinx client
http://us3.php.net/manual/en/book.sphinx.php

if you are writing your own solutions and using utf8, take care with
similar_text() or levenshtein(). i don't think they are designed for
multibyte strings. so if you are using utf8 they will probably report bigger
differences that you might expect. i wrote my own limited
damerau-levenshtein function for utf8.

even if you're using a single byte encoding, i would guess they ignore a
locale's collation. so say you set a german locale, ü will be regarded as
different from both u and ue. again, if you are searching against against
strings in a db table, the dbms may understand collations properly.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] DateTime/DateInterval/DatePeriod Class PHP source for older than PHP 5.3.0

2009-09-28 Thread jeff brown
So I'm jealous, the functionality in the DateTime class, DateInterval 
class and DatePeriod class are exactly what I need in my current 
application, but my Host is on PHP 5.2.10, which has a partial DateTime 
class, but not the others.  I'd like to add a:


--

if (!class_exists('DateTime')) {

/* definition of DateTime */

}
if (!class_exists('DateInterval')) {

/* definition of DateInterval */

}
if (!class_exists('DatePeriod')) {

/* definition of DatePeriod */

}

--

That way when my Hosting company gets its act together I won't break any 
code.


Are there any resources for me?  I'm willing to dig, and even downloaded 
the source to 5.3.0, only to find that the php class seems to be "faked" 
in the C code for /ext/date/date.[ch]


Which doesn't help me unless I compile it on my own.  I'm looking for a 
lighter weight solution, just the php code that's equivalent to the 
classes ... doesn't it exist somewhere?  A basis that Derick Rethans 
used to make it?


Jeff

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] intl extension on os x

2009-09-28 Thread Tom Worster
On 9/28/09 2:41 AM, "Tommy Pham"  wrote:

> - Original Message 
>> From: Tom Worster 
>> To: PHP General List 
>> Sent: Sunday, September 27, 2009 5:34:45 PM
>> Subject: [PHP] intl extension on os x
>> 
>> does anyone know how to install intl on os x 10.5?
>> 
>> it seems a libicu binary is included in os x but not with headers. fink has
>> a package for installing the headers. maybe that would allow pecl to install
>> the intl extension.
>> 
>> has anyone done this successfully? or know any other way to get intl running
>> on 10.5?
>> 
>> 
>> 
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> When Apple made the big change of OS a few years back, they switch to *BSD
> based OS, with the GUI from NeXT, which Apple bought. You should be able to
> compile most linux/unix codes on Mac though.  Have you looked at Apple's
> developer's resources/documentation?

yes indeed. often you can successfully compile and install on os x things
that run on freebsd or linux. but port configuration is often substantially
different and not entirely handled by autoconf. (even compiling php requires
some tricks.) in these cases i refer to google because people smarter than
me (one assumes, everything you read on the internet being true, of course)
often blog their recipe if the find one. but i found nothing for this
problem. that's why i asked here.

at this stage, i installed the fink package libicu36-dev-3.6.0-5, supposedly
libicu headers and it seems to have done something, i'm not entirely sure
exactly what. and i'm not convinced that the headers are for the same libicu
version that's in /usr/lib.

but somehow, though i'm not clear how one configures pecl source, i managed
to get pecl to compile and install the extension.

anyway, in the cli the command collator_create( 'en_US' ); did not provoke
an error, so maybe that works.

but if i add extension=intl.so to php.ini and restart apache, php says: PHP
Warning:  PHP Startup: Unable to load dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/intl.so'

so we're not done yet. if i get it done, maybe i'll blog my recipe.

freebsd, otoh, has a port for pecl-intl so it was trivial to install. 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] WYSIWYG editor to change textarea

2009-09-28 Thread Angelo Zanetti
Hi all, 

I have been looking to implement a WYSIWYG editor that will automatically
transform a  into a Rich text area / WYSIWYG. We have lots of
dynamic content that is pulled from a database and files. Therefore we cant
really change the  field.

I have tried the tinyMCE but its causing conflicts with some existing JS
code that cant really be rewritten.

A lot of other editors actually generate the rich text area in a strange way
and don't use the  field at all.

Are there any editors that you people will know of that operate in a similar
way to tinyMCE, IE you include the JS in your head and it will change all
the textarea fields to rich text areas?

Thanks in advance.

http://www.elemental.co.za 
http://www.wapit.co.za




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] WYSIWYG editor to change textarea

2009-09-28 Thread Ashley Sheridan
On Mon, 2009-09-28 at 22:30 +0200, Angelo Zanetti wrote:
> Hi all, 
> 
> I have been looking to implement a WYSIWYG editor that will automatically
> transform a  into a Rich text area / WYSIWYG. We have lots of
> dynamic content that is pulled from a database and files. Therefore we cant
> really change the  field.
> 
> I have tried the tinyMCE but its causing conflicts with some existing JS
> code that cant really be rewritten.
> 
> A lot of other editors actually generate the rich text area in a strange way
> and don't use the  field at all.
> 
> Are there any editors that you people will know of that operate in a similar
> way to tinyMCE, IE you include the JS in your head and it will change all
> the textarea fields to rich text areas?
> 
> Thanks in advance.
> 
> http://www.elemental.co.za 
> http://www.wapit.co.za
> 
> 
> 
> 
The one that I tend to use these days is FCKEditor. Poorly named I know,
but apparently those were the guys initials (he had mean parents who
weren't aware of the connotations in the English language)

I heard today as well that there is a new version of this out called
CKEditor (apparently he spoke to someone who knows about the English
connotations) although I've not yet looked into this myself.

Thanks,
Ash
http://www.ashleysheridan.co.uk




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Where's my memory going?!

2009-09-28 Thread Philip Thompson

Hi all.

I have a script that opens a socket, creates a persistent mysql  
connection, and loops to receive data. When the amount of specified  
data has been received, it calls a class which processes the data and  
inserts it into the database. Each iteration, I unset/destruct that  
class I call. However, the script keeps going up in memory and  
eventually runs out, causing a fatal error. Any thoughts on where to  
start to see where I'm losing my memory?


Thanks in advance,
~Philip

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Where's my memory going?!

2009-09-28 Thread Jim Lucas
Philip Thompson wrote:
> Hi all.
> 
> I have a script that opens a socket, creates a persistent mysql
> connection, and loops to receive data. When the amount of specified data
> has been received, it calls a class which processes the data and inserts
> it into the database. Each iteration, I unset/destruct that class I
> call. However, the script keeps going up in memory and eventually runs
> out, causing a fatal error. Any thoughts on where to start to see where
> I'm losing my memory?
> 
> Thanks in advance,
> ~Philip
> 

We cannot tell you anything without see an example of what your script is doing.

Let us see some code!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: WYSIWYG editor to change textarea

2009-09-28 Thread Ralph Deffke
I can recomment the YAHOO editor for that. seemed to me they are very
conflictless with other js code

http://developer.yahoo.com/yui/editor/

good luck
ralph_def...@yahoo.de


""Angelo Zanetti""  wrote in message
news:20090928203015.0512b99...@smtp1.vodamail.co.za...
> Hi all,
>
> I have been looking to implement a WYSIWYG editor that will automatically
> transform a  into a Rich text area / WYSIWYG. We have lots of
> dynamic content that is pulled from a database and files. Therefore we
cant
> really change the  field.
>
> I have tried the tinyMCE but its causing conflicts with some existing JS
> code that cant really be rewritten.
>
> A lot of other editors actually generate the rich text area in a strange
way
> and don't use the  field at all.
>
> Are there any editors that you people will know of that operate in a
similar
> way to tinyMCE, IE you include the JS in your head and it will change all
> the textarea fields to rich text areas?
>
> Thanks in advance.
>
> http://www.elemental.co.za
> http://www.wapit.co.za
>
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Where's my memory going?!

2009-09-28 Thread Ralph Deffke
well this sound clearly to me like you are not freeing resultsets you are not 
going to use anymore. In long scripts you have to take care of this. on short 
scripts you can be a bit weak on that, because the resultsets are closed and 
freed on script ending.

assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message 
news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com...
> Hi all.
> 
> I have a script that opens a socket, creates a persistent mysql  
> connection, and loops to receive data. When the amount of specified  
> data has been received, it calls a class which processes the data and  
> inserts it into the database. Each iteration, I unset/destruct that  
> class I call. However, the script keeps going up in memory and  
> eventually runs out, causing a fatal error. Any thoughts on where to  
> start to see where I'm losing my memory?
> 
> Thanks in advance,
> ~Philip

Re: [PHP] Where's my memory going?!

2009-09-28 Thread Philip Thompson

On Sep 28, 2009, at 4:18 PM, Jim Lucas wrote:


Philip Thompson wrote:

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of specified  
data
has been received, it calls a class which processes the data and  
inserts

it into the database. Each iteration, I unset/destruct that class I
call. However, the script keeps going up in memory and eventually  
runs
out, causing a fatal error. Any thoughts on where to start to see  
where

I'm losing my memory?

Thanks in advance,
~Philip



We cannot tell you anything without see an example of what your  
script is doing.


Let us see some code!


I was wondering if you were gonna ask that! Umm... I don't know if I  
can show you the code b/c it's not as trivial as I explained it above.  
I'll tell you what, I give you something to chew on and you let me  
know if it's enough.


core = new coreFunctions (false, 'interface');
parent::__construct ($this->core, $host, $port, $clients);
$this->readFunction = 'processData';
$this->startPersistentListener();
}

public function processData ($data)
{
if ($this->filetype == 'demographics') {
$demoImporter = new Demographics ();
$ret = $demoImporter->importFromDataStream ($data);
$demoImporter->__destruct();
unset ($demoImporter);
echo "Memory usage: " . number_format (memory_get_usage  
()) . "\n";

return $ret;
}
}
}

class Socket
{
public function startPersistentListener ()
{
// Create a persistent listening socket connection
$this->create();
$this->setOption(SOL_SOCKET, SO_KEEPALIVE, 1);
$this->bind();
$this->listen();
$this->clients = array($this->sock);

while ($this->isAlive) {
// Create the list of connected clients
$this->createClients();

if ($this->select() < 1) {
// No clients - go to the next iteration
continue;
}

$this->accept();
$this->read();
}
}
}

set_time_limit (0);
new SocketListener ();
?>

I stripped out a lot of code, but this is the basics. I have a  
listener class that extends the socket class. When the socket class  
receives some data, it calls the processData() method - which creates  
a new instance of the Demographics class. It destroys the instance  
after it's finished. The line where I echo the memory usage indicates  
that the memory continues to grow until it just explodes.


There's a lot more going on behind the scenes that *could* cause the  
memory leak, but hopefully this will give you somewhere to go.


Thanks!
~Philip

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Where's my memory going?!

2009-09-28 Thread Philip Thompson

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:

well this sound clearly to me like you are not freeing resultsets  
you are not going to use anymore. In long scripts you have to take  
care of this. on short scripts you can be a bit weak on that,  
because the resultsets are closed and freed on script ending.


assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com 
...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of specified
data has been received, it calls a class which processes the data and
inserts it into the database. Each iteration, I unset/destruct that
class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on where to
start to see where I'm losing my memory?

Thanks in advance,
~Philip


I am not using mysql_free_result(). Is that highly recommended by all?

Thanks,
~Philip

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Where's my memory going?!

2009-09-28 Thread jeff brown
Yes, that's the best way to clean up after yourself.  And you really 
should use that on anything you have sitting around daemon like.


Jeff

Philip Thompson wrote:

On Sep 28, 2009, at 4:27 PM, Ralph Deffke wrote:

well this sound clearly to me like you are not freeing resultsets you 
are not going to use anymore. In long scripts you have to take care of 
this. on short scripts you can be a bit weak on that, because the 
resultsets are closed and freed on script ending.


assumed u r using MySQL are u using mysql_free_result($result)

goog luck

ralph_def...@yahoo.de


"Philip Thompson"  wrote in message 
news:9c0b9c4c-5e64-4519-862b-8a3e1da4d...@gmail.com...

Hi all.

I have a script that opens a socket, creates a persistent mysql
connection, and loops to receive data. When the amount of specified
data has been received, it calls a class which processes the data and
inserts it into the database. Each iteration, I unset/destruct that
class I call. However, the script keeps going up in memory and
eventually runs out, causing a fatal error. Any thoughts on where to
start to see where I'm losing my memory?

Thanks in advance,
~Philip


I am not using mysql_free_result(). Is that highly recommended by all?

Thanks,
~Philip


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Re: WYSIWYG editor to change textarea

2009-09-28 Thread HallMarc Websites
> -Original Message-
> From: Ralph Deffke [mailto:ralph_def...@yahoo.de]
> Sent: Monday, September 28, 2009 5:18 PM
> To: php-general@lists.php.net
> Subject: [PHP] Re: WYSIWYG editor to change textarea
> 
> I can recomment the YAHOO editor for that. seemed to me they are very
> conflictless with other js code
> 
> http://developer.yahoo.com/yui/editor/
> 
> good luck
> ralph_def...@yahoo.de
> 
> 
> ""Angelo Zanetti""  wrote in message
> news:20090928203015.0512b99...@smtp1.vodamail.co.za...
> > Hi all,
> >
> > I have been looking to implement a WYSIWYG editor that will
> automatically
> > transform a  into a Rich text area / WYSIWYG. We have lots
> of
> > dynamic content that is pulled from a database and files. Therefore
> we
> cant
> > really change the  field.
> >
> > I have tried the tinyMCE but its causing conflicts with some existing
> JS
> > code that cant really be rewritten.
> >
> > A lot of other editors actually generate the rich text area in a
> strange
> way
> > and don't use the  field at all.
> >
> > Are there any editors that you people will know of that operate in a
> similar
> > way to tinyMCE, IE you include the JS in your head and it will change
> all
> > the textarea fields to rich text areas?
> >
> > Thanks in advance.
> >
> > http://www.elemental.co.za
> > http://www.wapit.co.za
> >

I will look at this Yahoo! thanks too. I wanted to throw my 2 cents in here:
TinyMCE was the one I usually recommended yet your experience has been one
of my biggest gripes about it. I would lean to believe that they were
attempting to "Dummy Proof" it and in doing so made it frustrating to use
unless, you learn how to use it the it was meant to be used and not how you
expect it. 


Thank you,
Marc Hall
HallMarc Websites
610.446.3346
 

__ Information from ESET Smart Security, version of virus signature
database 4465 (20090928) __

The message was checked by ESET Smart Security.

http://www.eset.com
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php