OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
php-general Digest 3 Sep 2007 20:32:59 -0000 Issue 4998

php-general-digest-helplists.php.net
Date: Mon Sep 03 2007 - 15:32:59 CDT


php-general Digest 3 Sep 2007 20:32:59 -0000 Issue 4998

Topics (messages 261630 through 261660):

Re: what is my dns ip address
        261630 by: Per Jessen
        261631 by: Olav Mřrkrid

clickbank (merchandise provider) for creditcard based internet online transaction.
        261632 by: Patrik Hasibuan

Re: Create a matrix gallery
        261633 by: Stut
        261636 by: Bastien Koert

amfphp
        261634 by: Nathan Wallis

Re: Pragmatically changing a "Record Number"
        261635 by: tedd
        261643 by: brian
        261654 by: tedd
        261657 by: brian

Generating foldout menus in php
        261637 by: Arno Kuhl
        261638 by: Richard Heyes
        261639 by: Zoltán Németh
        261641 by: Colin Guthrie
        261642 by: Richard Heyes
        261644 by: Zoltán Németh
        261645 by: Colin Guthrie
        261647 by: Richard Heyes
        261650 by: tedd
        261651 by: tedd

Re: php-general Digest 31 Aug 2007 16:34:36 -0000 Issue 4992
        261640 by: Michael Williams

Re: mail() takes too much time
        261646 by: Matthew Lasar
        261648 by: Colin Guthrie
        261649 by: brian
        261653 by: Stut
        261656 by: Colin Guthrie
        261659 by: Stut

Re: PHP Developer Required
        261652 by: mlists
        261655 by: tedd

Re: PHP/MySQL not playing nicely. Server drops connection.
        261658 by: Michael Williams

Re: PHP-VOX Project Advancement (PHP Text-To-Speech)
        261660 by: tedd

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


Olav Mørkrid wrote:

> the source of the problem is gethostbyaddr(). it seems to have a 4,5
> second timeout, so some lookups time out after 4,5 seconds, while most
> of them are resolved in < 0.1 second; a radically performance
> difference.

You can change the timeout be amending the options statement
in /etc/resolv.conf:

options timeout: 2 (2 seconds).

See 'man resolv.conf'.

/Per Jessen, ZĂĽrich

attached mail follows:


yeah but i assume this assumes you are on a unix machine and have
administrator rights. it would be nice to be able to look up ip
addresses swiftly and automatically on any machine and any operating
system running php.

On 03/09/07, Per Jessen <percomputer.org> wrote:
> Olav Mřrkrid wrote:
>
> > the source of the problem is gethostbyaddr(). it seems to have a 4,5
> > second timeout, so some lookups time out after 4,5 seconds, while most
> > of them are resolved in < 0.1 second; a radically performance
> > difference.
>
> You can change the timeout be amending the options statement
> in /etc/resolv.conf:
>
> options timeout: 2 (2 seconds).
>
> See 'man resolv.conf'.
>
>
>
> /Per Jessen, Zürich
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Dear all of my friends in this mailing-list,

Has anybody here ever tried creating a creditcard based internet online transaction with PHP to clickbank (http://www.clickbank.com)?

Which PHP Library should I use to develop the payment process? Can I use CURL for clickbank?

Among all of my friends in this mailing-list, has anybody ever get problem or find the disadvantage to use the service of clickbank?

Thank you very much in advance.
--
Patrik Hasibuan <patrikhpenguin-teknologi.com>
Junior Programmer

attached mail follows:


Humani Power wrote:
> hi list. I wonder if anyone can help me with this.
> i have a database with the file name of several images stored in a
> filesystem, and I want to create a table containing the image results of a
> query.
>
> this is my code
>
<snip>
> while ($rows=mysql_fetch_assoc($getpic))
> {
> extract ($rows);
> echo "<tr>";
> echo "<td><a href=editing_image.php?pic=".$rows['image_id']."><img
> src=".$ImageThumb.$rows['image_id'].".jpg></td>";
> }
<snip>
> With this code, I am able to see the thumb images with their respective link
> ok, but if I have a query with 40 results, I will have a big row of images.
> ____________________________________________________
>
> |pic1 | pic2 | pic3 | pic4 | pic5 | pic6 | pic7 | pic8 | pic9 | pic10 |
> ______________________________________________________
>
>
> What I want to to do is insert a new <td> after showing 5 thumb images, and
> continue with the next picture on the next row.
> something like this
> __________________________
> |pic1 | pic2 | pic3 | pic4 | pic5 |
> __________________________
> |pic6 | pic7 | pic8 | pic9 | pic10 |
> __________________________
> |pic11 | pic12 | pic13 |
> __________________

This is really quite simple...

$col = 1;
while ($rows=mysql_fetch_assoc($getpic))
{
     extract ($rows);
     if ($col == 1) echo "<tr>";
     echo "<td><a href=editing_image.php?pic=".$rows['image_id']."><img
src=".$ImageThumb.$rows['image_id'].".jpg></td>";
     if ($col++ == 5)
     {
         echo "</tr>";
         $col = 1;
     }
}

Not sure why you are using extract when you then go on to use $rows as
an array. Also, you're lacking quotes around the href in the link you
output, and also the src in the image. It's also missing a closing </a>
tag. And you should be using urlencode when putting values into a URL.
And while I'm at it, $row is more semantically correct than $rows.

Try this...

$col = 1;
while ($row = mysql_fetch_assoc($getpic))
{
     if ($col == 1) echo '<tr>';
     $image_id = urlencode($row['image_id']);
     echo '<td><a
href="editing_image.php?pic='.urlencode($image_id).'"><img
src="'.$ImageThumb.urlencode($image_id).'.jpg" /></a></td>';
     if ($col++ == 5)
     {
         echo '</tr>';
         $col = 1;
     }
}

-Stut

--
http://stut.net/

attached mail follows:


Hotmail sucks

but try this

[code]

$counter = 1;

while ($rows=mysql_fetch_assoc($getpic))
{

//close the tr tag after 5 photos usng the mod function to check the counter
if($counter % 5 == 0) {
  echo "";

//reset the counter
$counter = 1;
}

extract ($rows);
echo "";
echo "";

$counter++;

}

hth

bastien

}
?>

----------------------------------------> Date: Mon, 3 Sep 2007 04:30:29 -0400> From: jiumangmail.com> To: php-generallists.php.net> Subject: [PHP] Create a matrix gallery>> hi list. I wonder if anyone can help me with this.> i have a database with the file name of several images stored in a> filesystem, and I want to create a table containing the image results of a> query.>> this is my code>> include_once("../../../connection/connection.php");> ?>> > > Image Gallery> >> > //get the thumbsnails> $getpic=mysql_query("select * from rsiis_images")> or die(mysql_error());>>> while ($rows=mysql_fetch_assoc($getpic))> {> extract ($rows);> echo "";> echo " src=".$ImageThumb.$rows['image_id'].".jpg>";> }> ?>>> >> > > >> With this code, I am able to see the thumb images with their respective link> ok, but if I have a query with 40 results, I will have a big row of images.> ____________________________________________________>> |pic1 | pic2 | pic3 | pic4 | pic5 | pic6 | pic7 | pic8 | pic9 | pic10 |> ______________________________________________________>>> What I want to to do is insert a new after showing 5 thumb images, and> continue with the next picture on the next row.> something like this> __________________________> |pic1 | pic2 | pic3 | pic4 | pic5 |> __________________________> |pic6 | pic7 | pic8 | pic9 | pic10 |> __________________________> |pic11 | pic12 | pic13 |> __________________>>>> Thanks in advance.> Yamil

_________________________________________________________________
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE

attached mail follows:


Hey there,

 

I am running amfphp on my webserver locally and it works well when I use
localhost, so I change localhost to my computers local IP address which is
192.168.1.2 and then test it from another machine. Nothing happens, the
remote procedure does not get called.

 

Any ideas on this?

 

Thanks,

 

Nathan

attached mail follows:


At 10:27 AM +1000 9/3/07, Chris wrote:
>tedd wrote:
>>At 6:14 PM -0400 9/2/07, brian wrote:
>>>tedd wrote:
>>>>Hi to the original poster:
>>>>
>>>>Snip -- a lot of discussion
>>>>
>>>>Use the following code at your own peril.
>>>>
>>>>$dbQuery = "ALTER TABLE $dbtable ";
>>>>$dbQuery .= "DROP id, ";
>>>>$dbQuery .= "ADD id INT UNSIGNED NOT NULL AUTO_INCREMENT,";
>>>>$dbQuery .= "AUTO_INCREMENT = 1";
>>>>$result = mysql_query($dbQuery) or die("Could not renumber dB
>>>>$dbQuery" . mysql_error());
>>>>
>>>>The reason for not wanting to care about the auto_increment id is
>>>>that it is something that the database uses and really should not
>>>>be changed. If you want to have a sequential record number, then
>>>>add that field and alter it as you will, but leave the internal
>>>>workings of database alone.
>>>>
>>>>However, if you wish not to understand how all that works, then
>>>>use the code above -- it will renumber your auto_increment id
>>>>leaving no gaps.
>>>>
>>-snip-
>>
>>
>>How is that contrary to what I said?
>
>You are actually changing the id's in the database.
>
>Brian's example is making up an id to display (much like the excel
>row numbers) rather than actually changing the id in the database.

Please read what I said above, If you do, then you will see that I
advised against altering the index and recommend setting up another
field for displaying a record sequence.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


tedd wrote:
> At 10:27 AM +1000 9/3/07, Chris wrote:
>
>> tedd wrote:
>>
>>> At 6:14 PM -0400 9/2/07, brian wrote:
>>>
>>>> tedd wrote:
>>>
>>> How is that contrary to what I said?
>>
>> You are actually changing the id's in the database.
>>
>> Brian's example is making up an id to display (much like the excel row
>> numbers) rather than actually changing the id in the database.
>
> Please read what I said above, If you do, then you will see that I
> advised against altering the index and recommend setting up another
> field for displaying a record sequence.
>

It seemed to me that what you were suggesting was to either alter the
existing id or to create a second auto_increment field. Isn't there
already an auto_increment field in the table? I thought that that was
what this was all about: an increment that has gaps.

In any case, i can't see how that would help considering that, should
any of the rows then be deleted, we're back to the same problem: the
auto_increment field will have a gap. That's why the simplest way to
deal with this is to increment a counter var in the presentational
logic, given that this counter is for presentational purposes only and
is unnecessary to relate to any specific row. That's what the existing
id column is for (however "out of order" it may be).

brian

attached mail follows:


At 11:48 AM -0400 9/3/07, brian wrote:
>tedd wrote:
>>At 10:27 AM +1000 9/3/07, Chris wrote:
>>
>>>tedd wrote:
>>>
>>>>At 6:14 PM -0400 9/2/07, brian wrote:
>>>>
>>>>>tedd wrote:
>>>>
>>>>How is that contrary to what I said?
>>>
>>>You are actually changing the id's in the database.
>>>
>>>Brian's example is making up an id to display (much like the excel
>>>row numbers) rather than actually changing the id in the database.
>>
>>Please read what I said above, If you do, then you will see that I
>>advised against altering the index and recommend setting up another
>>field for displaying a record sequence.
>>
>
>It seemed to me that what you were suggesting was to either alter
>the existing id or to create a second auto_increment field. Isn't
>there already an auto_increment field in the table? I thought that
>that was what this was all about: an increment that has gaps.
>
>In any case, i can't see how that would help considering that,
>should any of the rows then be deleted, we're back to the same
>problem: the auto_increment field will have a gap. That's why the
>simplest way to deal with this is to increment a counter var in the
>presentational logic, given that this counter is for presentational
>purposes only and is unnecessary to relate to any specific row.
>That's what the existing id column is for (however "out of order" it
>may be).
>
>brian

Arrggg. No, I did not say create another auto_increment field -- I said:

Quote
The reason for not wanting to care about the auto_increment id is
that it is something that the database uses and really should not be
changed. If you want to have a sequential record number, then add
that field and alter it as you will, but leave the internal workings
of database alone.
Un-quote

Now, I do not know why what I said seemed to mean something different
to you, but my guess is that you didn't read it thoroughly.

As for the "gap" problem, there is no gap problem if you create
another field for record number and alter it to your liking (NOTE: I
did not say AUTO_INCREMENT). If you add/delete a record, then adjust
the "field for record number" accordingly. You don't have to adjust
the database's index to handle gaps.

I don't see the problem here other than misunderstanding what's been said.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


tedd wrote:
> At 11:48 AM -0400 9/3/07, brian wrote:
>
> Arrggg. No, I did not say create another auto_increment field -- I said:
>
> Quote
> The reason for not wanting to care about the auto_increment id is that
> it is something that the database uses and really should not be changed.
> If you want to have a sequential record number, then add that field and
> alter it as you will, but leave the internal workings of database alone.
> Un-quote
>
> Now, I do not know why what I said seemed to mean something different to
> you, but my guess is that you didn't read it thoroughly.

My bad. I see, now, that what you meant was, "This is how to re-set your
EXISTING auto_increment, AND, here's something else you can do." Yes, i
was confused about your intention.

> As for the "gap" problem, there is no gap problem if you create another
> field for record number and alter it to your liking (NOTE: I did not say
> AUTO_INCREMENT). If you add/delete a record, then adjust the "field for
> record number" accordingly. You don't have to adjust the database's
> index to handle gaps.

Well, yes, that would work also but is horribly inefficient because the
*entire table* must be altered any time a row is deleted.

> I don't see the problem here other than misunderstanding what's been said.

Well, not seperating data and presentation would be another problem,
IMO. What if the client decides that Roman notation is cooler? You have
to ask yourself what this 'counting column' is doing in your database.
Let PHP/Python/XSL/whatever take care of numbering the rows.

brian

attached mail follows:


This may not be directly php related but I'm hoping that generating the code
with PHP will keep it on topic.

I'm looking for a way to generate dropdown/foldout menus (horizontal and
vertical) on the fly, but all the javascript solutions I've seen use
absolute or relative pixel positioning, which means I can't use them because
I don't know at the time of generating a specific menu item how many pixels
across or down the preceding items have already used. I'm currently using a
javascript menu that works really well, but all the top-level menu items
have to be preset with specific x-y pixel coordinates, and all the
subsequent items are then relative to the top-level items. So I can generate
the second-level and subsequent items on the fly but not the top-level
items. Is there a way to use css or dhtml or something else (maybe something
in javascript that I missed) to do this?

Thanks
Arno

attached mail follows:


> I'm looking for a way to generate dropdown/foldout menus (horizontal and
> vertical) on the fly, but all the javascript solutions I've seen use
> absolute or relative pixel positioning, which means I can't use them because
> I don't know at the time of generating a specific menu item how many pixels
> across or down the preceding items have already used. I'm currently using a
> javascript menu that works really well, but all the top-level menu items
> have to be preset with specific x-y pixel coordinates, and all the
> subsequent items are then relative to the top-level items. So I can generate
> the second-level and subsequent items on the fly but not the top-level
> items. Is there a way to use css or dhtml or something else (maybe something
> in javascript that I missed) to do this?

Is this: http://www.phpguru.org/static/dynContext.example.html what you
mean?

--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

attached mail follows:


2007. 09. 3, hétfő keltezéssel 15.09-kor Richard Heyes ezt írta:
> > I'm looking for a way to generate dropdown/foldout menus (horizontal and
> > vertical) on the fly, but all the javascript solutions I've seen use
> > absolute or relative pixel positioning, which means I can't use them because
> > I don't know at the time of generating a specific menu item how many pixels
> > across or down the preceding items have already used. I'm currently using a
> > javascript menu that works really well, but all the top-level menu items
> > have to be preset with specific x-y pixel coordinates, and all the
> > subsequent items are then relative to the top-level items. So I can generate
> > the second-level and subsequent items on the fly but not the top-level
> > items. Is there a way to use css or dhtml or something else (maybe something
> > in javascript that I missed) to do this?
>
> Is this: http://www.phpguru.org/static/dynContext.example.html what you
> mean?
>

hmm on Linux/Firefox I can not see any custom menu... there's a box
saying "Right click here to see menu" - I tried right click, left click,
double click there and nothing happens. (on right click the standard
firefox context menu appears)

greets
Zoltán Németh

> --
> Richard Heyes
> +44 (0)800 0213 172
> http://www.websupportsolutions.co.uk
>
> Knowledge Base and HelpDesk software
> that can cut the cost of online support
>

attached mail follows:


Zoltán Németh wrote:
> hmm on Linux/Firefox I can not see any custom menu... there's a box
> saying "Right click here to see menu" - I tried right click, left click,
> double click there and nothing happens. (on right click the standard
> firefox context menu appears)

Works for me with FF2 on Linux. Perhaps some extension is getting in the
way?

Col

attached mail follows:


Colin Guthrie wrote:
> Zoltán Németh wrote:
>> hmm on Linux/Firefox I can not see any custom menu... there's a box
>> saying "Right click here to see menu" - I tried right click, left click,
>> double click there and nothing happens. (on right click the standard
>> firefox context menu appears)
>
> Works for me with FF2 on Linux. Perhaps some extension is getting in the
> way?

Really? That surprises me since the "layer" it uses is (or was) IE only.
I guess FF2 supports it.

--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

attached mail follows:


2007. 09. 3, hétfő keltezéssel 16.34-kor Colin Guthrie ezt írta:
> Zoltán Németh wrote:
> > hmm on Linux/Firefox I can not see any custom menu... there's a box
> > saying "Right click here to see menu" - I tried right click, left click,
> > double click there and nothing happens. (on right click the standard
> > firefox context menu appears)
>
> Works for me with FF2 on Linux. Perhaps some extension is getting in the
> way?

I checked with 1.5.0.12 and 2.0.0.6, on two separate machines, both have
WebDeveloper and AdBlock plus plugins installed and both run on
(different versions of) Ubuntu...
so it might be WebDeveloper or the AdBlock plus, I don't know...

greets
Zoltán Németh

>
> Col
>

attached mail follows:


Richard Heyes wrote:
> Colin Guthrie wrote:
>> Zoltán Németh wrote:
>>> hmm on Linux/Firefox I can not see any custom menu... there's a box
>>> saying "Right click here to see menu" - I tried right click, left click,
>>> double click there and nothing happens. (on right click the standard
>>> firefox context menu appears)
>>
>> Works for me with FF2 on Linux. Perhaps some extension is getting in the
>> way?
>
> Really? That surprises me since the "layer" it uses is (or was) IE only.
> I guess FF2 supports it.

I don't make the fries, I just read the menu ;)

Col

attached mail follows:


Zoltán Németh wrote:
> 2007. 09. 3, hétfő keltezéssel 16.34-kor Colin Guthrie ezt írta:
>> Zoltán Németh wrote:
>>> hmm on Linux/Firefox I can not see any custom menu... there's a box
>>> saying "Right click here to see menu" - I tried right click, left click,
>>> double click there and nothing happens. (on right click the standard
>>> firefox context menu appears)
>> Works for me with FF2 on Linux. Perhaps some extension is getting in the
>> way?
>
> I checked with 1.5.0.12 and 2.0.0.6, on two separate machines, both have
> WebDeveloper and AdBlock plus plugins installed and both run on
> (different versions of) Ubuntu...
> so it might be WebDeveloper or the AdBlock plus, I don't know...

Wow, I've (now) tried it mine (1.5.13) and it seems to work flawlessly.
Shocking.

--
Richard Heyes
+44 (0)800 0213 172
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

attached mail follows:


At 4:07 PM +0200 9/3/07, Arno Kuhl wrote:
>This may not be directly php related but I'm hoping that generating the code
>with PHP will keep it on topic.
>
>I'm looking for a way to generate dropdown/foldout menus (horizontal and
>vertical) on the fly, but all the javascript solutions I've seen use
>absolute or relative pixel positioning, which means I can't use them because
>I don't know at the time of generating a specific menu item how many pixels
>across or down the preceding items have already used. I'm currently using a
>javascript menu that works really well, but all the top-level menu items
>have to be preset with specific x-y pixel coordinates, and all the
>subsequent items are then relative to the top-level items. So I can generate
>the second-level and subsequent items on the fly but not the top-level
>items. Is there a way to use css or dhtml or something else (maybe something
>in javascript that I missed) to do this?
>
>Thanks
>Arno

Arno:

There's really no way to do this just using php. I can envision a way
to use php with a couple of other languages to provide drop-down and
pop-out menus, but that would be more complicated than just using css
with js, like so:

http://sperling.com/examples/menuh/

http://sperling.com/examples/menuv/

Why complicate your life?

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


At 3:09 PM +0100 9/3/07, Richard Heyes wrote:
>>I'm looking for a way to generate dropdown/foldout menus (horizontal and
>>vertical) on the fly, but all the javascript solutions I've seen use
>>absolute or relative pixel positioning, which means I can't use them because
>>I don't know at the time of generating a specific menu item how many pixels
>>across or down the preceding items have already used. I'm currently using a
>>javascript menu that works really well, but all the top-level menu items
>>have to be preset with specific x-y pixel coordinates, and all the
>>subsequent items are then relative to the top-level items. So I can generate
>>the second-level and subsequent items on the fly but not the top-level
>>items. Is there a way to use css or dhtml or something else (maybe something
>>in javascript that I missed) to do this?
>
>Is this: http://www.phpguru.org/static/dynContext.example.html what you mean?
>
>--
>Richard Heyes
>+44 (0)800 0213 172
>http://www.websupportsolutions.co.uk

That doesn't do anything in my browser (Safari). Besides, I don't
have a right click button.

That's one of the problems one runs into trying to make menus for all browsers.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


> Are you sure that Apache is running and accepting connections to /
> ~michwill? Does a regular HTML page show up ok?

Yeah, static pages, and regular php pages load fine. It's only when
I bring MySQL into the mix that things go awry.

> Have you checked the server error log?

If by "server" you mean Apache or PHP specifically, then yes. There
is nothing telling there.

> What does your script look like where it connects? Does it simply
> die() without a message? Try creating a test script with header
> ('Content-type: text/plain') at the top. Then print out messages
> after each step. (beginning of script, opening a DB connection, etc.)

It literally dies with what I posted:

Safari can’t open the page “http://localhost/~michwill/mysqltest.php”
because the server unexpectedly dropped the connection, which
sometimes occurs when the server is busy. You might be able to open
the page later.

Oddly enough, when I use MAMP, instead of the source install, this
doesn't occur.

> How are you accessing the database?

I've stripped the PHP script to simply read as follows:

           <?php

             header('Content-type: text/plain');

             echo "Beginning PHP Script!";

             $connection_error = "We apologize for the inconvenience,
but it appears that our database server is down.<br>";
             $connection_error .= "Please try again later.";

             $host = "localhost";
             $user = "michael";
             $db_pass = "michael";

             $connect = mysql_connect($host,$user,$db_pass) or die
($connection_error . mysql_error());

           ?>

. . .the error is no different, and it doesn't output anything that
is "echo"ed. I've ensured that all permissions are in place with the
MySQL database as well. I can manually log in just fine. I'm at a
loss.

Regards,
Michael

attached mail follows:


I run pretty simple mail group distribution program that uses
php/mysql and the mail() function. I adapted it from an open source
script. Most of the time it runs well. But it does take a while to
run through all 150 members of the list. So I'm half glad that I
don't have a list of 1000 people or more.

Any way to optimize the mail function in terms of speed? Probably too
vague a question, sorry.

/ml

At 07:50 AM 9/2/2007, you wrote:
>Stut wrote:
> > Unless your script is actually hanging for the 4-6 hours this problem
> > has nothing to do with PHP.
> >
> > How mail is delivered depends on the OS you are using, but usually it
> > will get passed to a local MTA which then handles delivering it, at
> > which point PHP involvement ends.
> >
> > I suggest you look at the Received headers in the messages your getting.
> > You should be able to see which server is causing the delay.
>
>Yup, 100% agree that it's not PHP.
>
>Reasons for delays can include a dodgy ISP just taking a long time to
>process things, or more typically some form of "greylisting" e.g. one
>MTA deliberately telling the delivering MTA to P*ss off for a while -
>compliant servers will resend the mail after a while at which point it
>will be accepted. This is a spam prevention technique. See:
>http://en.wikipedia.org/wiki/Greylisting
>
>Col
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>--
>No virus found in this incoming message.
>Checked by AVG Free Edition.
>Version: 7.5.484 / Virus Database: 269.13.2/983 - Release Date:
>9/1/2007 4:20 PM

attached mail follows:


Matthew Lasar wrote:
> I run pretty simple mail group distribution program that uses php/mysql
> and the mail() function. I adapted it from an open source script. Most
> of the time it runs well. But it does take a while to run through all
> 150 members of the list. So I'm half glad that I don't have a list of
> 1000 people or more.
>
> Any way to optimize the mail function in terms of speed? Probably too
> vague a question, sorry.

Yeah it is fairly vauge.

I guess one obvious way is to ask whether or not you send the same mail
content to people but just do it 150 times? Or whether you customise the
mail to each person putting in e.g. their name at the top etc. If the
former then you can send the mails in batches of about 30-50 at a time
using the BCC header rather than a direct To header (set the To address
to e.g. yourself or a dummy address that works but is a bitbucket). That
way there will be considerably less calls to mail() to process.

The other way would be to write the mails to a database and process them
later. You could write a special cronjob that runs every few minutes and
pushes them out in the background. It could run every minute or two
(with file locking to prevent more than one instance at a time) and
either process all mails it can or just do about 50 of them and then
quit and leave the rest for the next run. Obviously you have to manage
it to make sure that it can physically catch up with how many mails are
being generated but this isn't too hard.

There are lots of other ways too - I've even seen some people program a
MySQL UDF to send mail and let the database do the work, but I would
have serious doubts about that approach for this use!!

Col

attached mail follows:


Matthew Lasar wrote:
> I run pretty simple mail group distribution program that uses php/mysql
> and the mail() function. I adapted it from an open source script. Most
> of the time it runs well. But it does take a while to run through all
> 150 members of the list. So I'm half glad that I don't have a list of
> 1000 people or more.
>
> Any way to optimize the mail function in terms of speed? Probably too
> vague a question, sorry.
>

Have a look at the Swift Mailer package:

http://www.swiftmailer.org/

I use it to send out well over 1000 mails at a time and it works quite
fine for me. Check out the anti-flood extension for sending large batches:

$swift = new Swift(new Swift_Connection_SMTP('localhost'), 'domain.org');
        

/* 100 mails per batch with a 30 second pause between batches
  */
$swift->attachPlugin(new Swift_Plugin_AntiFlood(100, 30), 'anti-flood');

/* list of recipients is an object wrapping an array
  */
$recipients = new Swift_RecipientList();
$recipients->addTo('foobar.com', 'foo bar');

/* headers
  */
$message = new Swift_Message('the subject');
$message->setCharset('utf-8');
$message->setReplyTo('replydomain.com');
$message->setReturnPath('returndomain.com');
$message->headers->set('Errors-To', 'errorsdomain.com');

/* multipart is a breeze
  */
$message->attach(new Swift_Message_Part($plain_content));
$message->attach(new Swift_Message_Part($html_content, 'text/html'));

/* if you're sending the mails from, eg. an admin page ...
  */
set_time_limit(0);
ignore_user_abort();
flush();

/* send it out
  */
$num_sent = $swift->batchSend($message, $recipients, new
Swift_Address('fromdomain.com', 'from'));

This really should be rolled into the PEAR project, IMO.

brian

attached mail follows:


Matthew Lasar wrote:
> I run pretty simple mail group distribution program that uses php/mysql
> and the mail() function. I adapted it from an open source script. Most
> of the time it runs well. But it does take a while to run through all
> 150 members of the list. So I'm half glad that I don't have a list of
> 1000 people or more.
>
> Any way to optimize the mail function in terms of speed? Probably too
> vague a question, sorry.

Don't use the mail function. On a unix-based system it will pass the
message directly to sendmail which will attempt to deliver the message
in realtime. When you're sending a large amount of mail that sucks.

Your best option is to switch to using a system that connects to the
SMTP server on localhost directly. That way you can dump each message on
to the local MTA quickly and then forget about it.

As an example one of the newletters I maintain has over 300,000
subscribers and the system that sends the emails (written in PHP of
course) takes less than 6 hours. The mail queue on that machine gets
very big and then it's up to the MTA to work through sending the
messages as quickly as it can (which usually takes about 28 hours).

-Stut

--
http://stut.net/

attached mail follows:


Stut wrote:
> Matthew Lasar wrote:
>> I run pretty simple mail group distribution program that uses
>> php/mysql and the mail() function. I adapted it from an open source
>> script. Most of the time it runs well. But it does take a while to run
>> through all 150 members of the list. So I'm half glad that I don't
>> have a list of 1000 people or more.
>>
>> Any way to optimize the mail function in terms of speed? Probably too
>> vague a question, sorry.
>
> Don't use the mail function. On a unix-based system it will pass the
> message directly to sendmail which will attempt to deliver the message
> in realtime. When you're sending a large amount of mail that sucks.
>
> Your best option is to switch to using a system that connects to the
> SMTP server on localhost directly. That way you can dump each message on
> to the local MTA quickly and then forget about it.

I don't think this is correct, at least on my system. I know this
because I deliberatly ban internal machines on my network from
delivering mail to outside server (internal LAN cannot connect to port
25 on any system other than our gateway - this is to stop any windows
machines that may sneak into my network from spamming the world!).

When I test web apps locally I have to watch to override email addresses
such that I don't try to sent to real people but when I forget, they all
end up stuck in my local machine's MTA. So for that reason, mail() must
speak to my MTA, not try to deliver directly. Perhaps it depends on your
sendmail implementation? I prefer postfix (which has a sendmail
compatible binary). YMMV.

Col.

attached mail follows:


Colin Guthrie wrote:
> Stut wrote:
>> Matthew Lasar wrote:
>>> I run pretty simple mail group distribution program that uses
>>> php/mysql and the mail() function. I adapted it from an open source
>>> script. Most of the time it runs well. But it does take a while to run
>>> through all 150 members of the list. So I'm half glad that I don't
>>> have a list of 1000 people or more.
>>>
>>> Any way to optimize the mail function in terms of speed? Probably too
>>> vague a question, sorry.
>> Don't use the mail function. On a unix-based system it will pass the
>> message directly to sendmail which will attempt to deliver the message
>> in realtime. When you're sending a large amount of mail that sucks.
>>
>> Your best option is to switch to using a system that connects to the
>> SMTP server on localhost directly. That way you can dump each message on
>> to the local MTA quickly and then forget about it.
>
> I don't think this is correct, at least on my system. I know this
> because I deliberatly ban internal machines on my network from
> delivering mail to outside server (internal LAN cannot connect to port
> 25 on any system other than our gateway - this is to stop any windows
> machines that may sneak into my network from spamming the world!).
>
> When I test web apps locally I have to watch to override email addresses
> such that I don't try to sent to real people but when I forget, they all
> end up stuck in my local machine's MTA. So for that reason, mail() must
> speak to my MTA, not try to deliver directly. Perhaps it depends on your
> sendmail implementation? I prefer postfix (which has a sendmail
> compatible binary). YMMV.

It depends a lot on how your machine is configured, but the way I
described it is usually the way it works. Note that if sendmail cannot
send the messages immediately it will pass it into the local mail queue
and that's probably what's happening on your system because sendmail
will find port 25 blocked.

-Stut

--
http://stut.net/

attached mail follows:


Wow!

Spend $100K on a university degree in computer science, work
successfully for five years with all the major technologies, and then
get paid $25 per hour?

My auto mechanic charges an average of $99 per hour.

Sounds like a great deal for the university. Maybe the successful
candidate can work off his student loans.

Kind of like buying from the "company store", eh?

On Fri, 2007-08-31 at 11:46 -0400, Greg Gay wrote:
> Title: Web Applications Developer
>
> Open August 30, 2007,
>
> Closing September 14, 2007
>
> Formal Education: University Degree in computer science/engineering or
> related discipline
>
> Employer: University of Toronto, Faculty of Information Studies,
> Adaptive Technology Resource Centre,
>
> Description: Under the direction of the Project Manager, the successful
> applicant will take a leading role in the development of PHP web
> applications, and participate through these projects in a number of open
> source communities, assisting with community support, assisting clients
> developing functional specifications, and assisting with development and
> maintenance of a number of open source community Web sites.
> Opportunities will also be available to participate in a broad range of
> development projects under taken at the centre, working with
> international and local groups, government, corporate, health care, and
> not for profit sectors, among others.
>
> Experience: At least five years experience working in team programming
> environment. Advanced knowledge of PHP web application development.
> Working knowledge of SQL, Javascript, AJAX, JAVA, XML, SOAP, HTML, CSS
> and working in a distributed programming environment using Subversion.
> Comfortable working in both Windows and Linux environments. Working
> knowledge of Apache and Tomcat. Understanding of Web accessibility and
> working in open source development projects would be an asset
>
> Other: Flexibility, initiative and the ability to work and learn
> independently. Excellent communication skills and an ability to
> communicate technical details courteously and clearly to non-technical
> users.
>
> Starting Rate: $25/hr/CAD + 4% vacation pay
>
> Appointment Type: One year renewable contract
>
> Percentage of FTE: 100
>
> Location: Toronto, Ontario, Canada
>
> Forward Resume to infoatutor.ca
>

attached mail follows:


At 1:47 PM -0400 9/3/07, mlists wrote:
>Wow!
>
>Spend $100K on a university degree in computer science, work
>successfully for five years with all the major technologies, and then
>get paid $25 per hour?

You can really get that much?

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

attached mail follows:


On Sep 3, 2007, at 11:12 AM, Michael Williams wrote:

> Are you sure that Apache is running and accepting connections to /
> ~michwill? Does a regular HTML page show up ok?

Yeah, static pages, and regular php pages load fine. It's only when
I bring MySQL into the mix that things go awry.

> Have you checked the server error log?

If by "server" you mean Apache or PHP specifically, then yes. There
is nothing telling there.

> What does your script look like where it connects? Does it simply
> die() without a message? Try creating a test script with header
> ('Content-type: text/plain') at the top. Then print out messages
> after each step. (beginning of script, opening a DB connection, etc.)

It literally dies with what I posted:

Safari can’t open the page “http://localhost/~michwill/mysqltest.php”
because the server unexpectedly dropped the connection, which
sometimes occurs when the server is busy. You might be able to open
the page later.

Oddly enough, when I use MAMP, instead of the source install, this
doesn't occur.

> How are you accessing the database?

I've stripped the PHP script to simply read as follows:

           <?php

             header('Content-type: text/plain');

             echo "Beginning PHP Script!";

             $connection_error = "We apologize for the inconvenience,
but it appears that our database server is down.<br>";
             $connection_error .= "Please try again later.";

             $host = "localhost";
             $user = "michael";
             $db_pass = "michael";

             $connect = mysql_connect($host,$user,$db_pass) or die
($connection_error . mysql_error());

           ?>

. . .the error is no different, and it doesn't output anything that
is "echo"ed. I've ensured that all permissions are in place with the
MySQL database as well. I can manually log in just fine. I'm at a
loss.

Regards,
Michael

attached mail follows:


At 1:02 PM -0400 9/3/07, Daniel Brown wrote:
> > For those of you who aren't hosted with me at PilotPig
> >(http://www.pilotpig.net/) but may be interested in the advancement of
> >the PHP TTS module that I've been working on (if you're not aware,
> >search the list archives ~May, 2007), we're unofficially at version
> >0.6.6 right now.
> >
> > In the latest build, which so far is just on the PilotPig servers
> >(and actually live for customers right now), the speech synthesis
> >function works as follows:
> >
> > <? txt2wav($text,$fileout,$duration,$pitch,$stddev); ?>

-snip-

> If anyone has any questions or anything, just let me know. I just
> >wanted to apprise those on the list who were interested (some of which
> >were involved) in the progress.

Daniel:

Damn, that's mondo slick. It's everything I wanted when we first
started this idea. You did a great job! Congrats!!!

You may review my first attempt at implementing your work here:

http://www.php1.net/b/speech/

This going to be great!

Cheers,

tedd

PS: If anyone has any problems with hearing this, please let us know.
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com