|
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 9 Jun 2006 07:51:32 -0000 Issue 4175
php-general-digest-help
lists.php.net
Date: Fri Jun 09 2006 - 02:51:32 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 9 Jun 2006 07:51:32 -0000 Issue 4175
Topics (messages 237645 through 237666):
Re: reset a resource?
237645 by: Brad Bonkoski
237646 by: Ben Liu
Re: pop-up window in php???
237647 by: Chuck Anderson
Re: Restrict uploaded scripts
237648 by: Mathias Bundgaard Svesson
237649 by: Mathias Bundgaard Svesson
237650 by: tedd
237662 by: Mathias Bundgaard Svesson
Re: Gzinflate on a string that has been base_64 encoded in Windows
237651 by: Chris
binary zero evaluates as true!?
237652 by: Jon
237654 by: D. Dante Lorenso
237657 by: Jon
237658 by: D. Dante Lorenso
remove last comma in string
237653 by: weetat
237655 by: D. Dante Lorenso
237656 by: Chris
transfer file
237659 by: kristianto adi widiatmoko
Update table to get consecutive Primary keys
237660 by: Antonio Bassinger
237661 by: Chris
237664 by: Larry Garfield
mail() function dying half way through.
237663 by: Dave M G
237665 by: Chris
substring with numric values
237666 by: Jonas Rosling
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Perhaps this will help:
http://www.php.net/manual/en/function.mysql-data-seek.php
-brad
sam wrote:
>
> After I've looped through a resource do I have to run the query again
> to load up 'mysql_fetch_assoc' or is there some kind of reset
> function I can't find?
>
> $q = "SELECT * FROM table;
> $s = mysql_query($q, $pe) or die(mysql_error());
> while ($row_s = mysql_fetch_assoc($s)) {
> echo $i++;
> }
>
> outputs "12345..." for each row of table
>
>
> while ($row_s2 = mysql_fetch_assoc($q)) {
> ...
> }
>
and $q is your query, I'm surprised this does not throw an error, unless
you snipped some other code out of there...
> outputs ""
>
>
> Thanks
>
attached mail follows:
sorry, mysql_data_seek()
On 6/8/06, sam <php
itab.com> wrote:
>
> After I've looped through a resource do I have to run the query again
> to load up 'mysql_fetch_assoc' or is there some kind of reset
> function I can't find?
>
> $q = "SELECT * FROM table;
> $s = mysql_query($q, $pe) or die(mysql_error());
> while ($row_s = mysql_fetch_assoc($s)) {
> echo $i++;
> }
>
> outputs "12345..." for each row of table
>
>
> while ($row_s2 = mysql_fetch_assoc($q)) {
> ...
> }
>
> outputs ""
>
>
> Thanks
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
Michelle Konzack wrote:
> Am 2006-05-29 11:56:43, schrieb siavash1979
telus.net:
>
>> ok, maybe I didn't make my question too clear. I was mostly wondering
>> if there
>> is a way to do it in PHP rather than Javascript. I would prefer only
>> using php.
>>
>
> Maybe it can be done, like,
>
> 1) Client fill out a form
> 2) Client klick the Submit Button
> 3) The php script on the server get the data
> and store it temporary
> 4) The php script on the server send back a HTML page
> which open a new (popup) window with the question
> 5) Client must confirm
> 6) The php script on the server get the confirmation
> and do something wit the previously sored data
>
> Greetings
> Michelle Konzack
>
>
>
You can not specify the window parameters (a popup) without using
Javascript.
You are correct, tough. You could load a new page asking them to confirm
(I do this a lot with scripts that delete something - "are you sure?"),
but not in a popup window.
--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Everyone's journey should be different,
so that we all are enriched
in new and endless ways
*****************************
attached mail follows:
Restrict them not to overwrite other modules or overwrite the CMS
itself. Each module should have it's own directory, and it shouldn't be
allowed to change anything outside it.
tor, 08 06 2006 kl. 21:49 +1000, skrev chris smith:
> On 6/8/06, Mathias Bundgaard Svesson <freaken
freaken.dk> wrote:
> > Hi!
> > I'm trying to create a CMS where it should be posible to upload script
> > modules. Those modules should mostly be made by myself, but it is
> > posible for others to create scripts too. My question is, is it posible
> > to restrict the modules to their own directory so they don't overwrite
> > some of the other modules or the CMS itself?
>
> Restrict them to do what exactly?
>
attached mail follows:
Restrict them not to overwrite other modules or overwrite the CMS
itself. Each module should have it's own directory, and it shouldn't be
allowed to change anything outside it.
tor, 08 06 2006 kl. 21:49 +1000, skrev chris smith:
> On 6/8/06, Mathias Bundgaard Svesson <freaken
freaken.dk> wrote:
> > Hi!
> > I'm trying to create a CMS where it should be posible to upload script
> > modules. Those modules should mostly be made by myself, but it is
> > posible for others to create scripts too. My question is, is it posible
> > to restrict the modules to their own directory so they don't overwrite
> > some of the other modules or the CMS itself?
>
> Restrict them to do what exactly?
>
attached mail follows:
At 10:37 PM +0200 6/8/06, Mathias Bundgaard Svesson wrote:
>Restrict them not to overwrite other modules or overwrite the CMS
>itself. Each module should have it's own directory, and it shouldn't be
>allowed to change anything outside it.
>
>tor, 08 06 2006 kl. 21:49 +1000, skrev chris smith:
>> On 6/8/06, Mathias Bundgaard Svesson <freaken
freaken.dk> wrote:
>> > Hi!
>> > I'm trying to create a CMS where it should be posible to upload script
>> > modules. Those modules should mostly be made by myself, but it is
>> > posible for others to create scripts too. My question is, is it posible
>> > to restrict the modules to their own directory so they don't overwrite
> > > some of the other modules or the CMS itself?
Mathias:
Well then, how about this?
You can create a "uniquely" named id by using:
$unique_id = md5(uniqid(microtime(), true));
and then use that name as a folder for each person submitting scripts OR use the unique id as a suffix for their cms file. Either way, it should stop persons from overwriting cms files.
I would also suggest that you keep track of these id's in a dB. If you are still concerned about two people having the same unique, then you could search the dB to see if the recently created id exist. If it does, then generate another one.
I use a similar method for making sure that the images I upload have unique names.
hth's
tedd
--
------------------------------------------------------------------------------------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
Wouldn't they still be able to overwrite each other?
I don't think I expressed myself clearly. The point of the protection is
to keep the scripts from overwriting each other on purpose. It was a
protection that would make it posible to upload scripts, even if you
were not completly sure they were safe.
tor, 08 06 2006 kl. 17:30 -0400, skrev tedd:
> At 10:37 PM +0200 6/8/06, Mathias Bundgaard Svesson wrote:
> >Restrict them not to overwrite other modules or overwrite the CMS
> >itself. Each module should have it's own directory, and it shouldn't be
> >allowed to change anything outside it.
> >
> >tor, 08 06 2006 kl. 21:49 +1000, skrev chris smith:
> >> On 6/8/06, Mathias Bundgaard Svesson <freaken
freaken.dk> wrote:
> >> > Hi!
> >> > I'm trying to create a CMS where it should be posible to upload script
> >> > modules. Those modules should mostly be made by myself, but it is
> >> > posible for others to create scripts too. My question is, is it posible
> >> > to restrict the modules to their own directory so they don't overwrite
> > > > some of the other modules or the CMS itself?
>
> Mathias:
>
> Well then, how about this?
>
> You can create a "uniquely" named id by using:
>
> $unique_id = md5(uniqid(microtime(), true));
>
> and then use that name as a folder for each person submitting scripts OR use the unique id as a suffix for their cms file. Either way, it should stop persons from overwriting cms files.
>
> I would also suggest that you keep track of these id's in a dB. If you are still concerned about two people having the same unique, then you could search the dB to see if the recently created id exist. If it does, then generate another one.
>
> I use a similar method for making sure that the images I upload have unique names.
>
> hth's
>
> tedd
>
>
>
attached mail follows:
Venky wrote:
> Greetings!
>
> I have a long piece of string that is apparently a PNG image which has been
> base_64 decoded in an XML file. I can retreive this string without problem.
> The string is in $mystra
>
> $pngdata = base64_decode($mystra);
> $pngdata = gzinflate($pngdata);
>
> When i try to gzinflate it , i get a warning that says "data error" and
> if i
> write pngdata to a binary file using fopen, there is 0 bytes (because of
> the
> warning).
>
> If i just write the base_64 decoded data to a binary file, then I can't
> open
> the file as a gziped file. (it is not a valid gzip'ed file)
>
>> From the person who sent me the XML file, what I was told
>
> the base_64 decoded data will give me the deflated binary array for the
> image, which I would need to inflate using an InflaterInputStream, and as a
> result, I will get the PNG file that is represented in $mystra.
>
> I probably need to add some PNG headers to it and/or explode the base_64
> decoded data and then add headers to it.
>
> I am getting quite lost here. Can anyone provide some hints please?
Hmm, a couple of things. Do you get it base64_encoded or decoded? You're
using "decode" as both terms so it's confusing for us.
Does the xml feed give you it inflated or deflated? gzdeflate will only
work if it is already inflated with gzinflate.
Can you get the other person to show you the code of how he puts the
image into the xml feed? That will tell you exactly what you need to "undo".
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
Seriously guys... am I completely missing something important here? An
empty array evaluates as false. The null character evaluates as false.
The STRING "0" even evaluates as false yet a binary zero does not?
Even better yet bindec() doesn't appear to be binary safe so it will
work for a string representation of binary data where the 0's and 1's
are ascii characters but pass it an actual binary string and it always
returns 0.
(sigh)
Someone help me understand this. Isn't this a bug or oversight?
attached mail follows:
Jon wrote:
> Seriously guys... am I completely missing something important here?
> An empty array evaluates as false. The null character evaluates as
> false. The STRING "0" even evaluates as false yet a binary zero does
> not?
>
> Even better yet bindec() doesn't appear to be binary safe so it will
> work for a string representation of binary data where the 0's and 1's
> are ascii characters but pass it an actual binary string and it always
> returns 0.
>
> (sigh)
>
> Someone help me understand this. Isn't this a bug or oversight?
The character '0' (zero) is not the same as a byte with all bits turned off.
(char) '0' = (binary) '00110000' = ord('0') = (int) 48
'bindec' returns the decimal equivalent of the binary number represented
by the binary_string argument. Note the BINARY STRING key word. I'm
guessing a Binary String is a string consisting of the characters '0' or
'1' not bits. Each character is 8 bits, so a binary string is a
sequence of the characters #48 and #49 from the ASCII table.
The 'character' ZERO is written with bits 00110000 in binary. This
binary could be interpreted as either a character or an integer. If the
binary is read as an integer, you'll get INT 48. INT 48 is NOT FALSE.
Casting from string to int to 'binary string' is done even when you
might not want it. Are you sure you are evaluating your binary
'00000000' properly as you claim? Send a sample code, otherwise, see
the following example:
--------------------------------------------------
<pre>
<?php
$zero = (string)'0';
$one = (string)'1';
var_dump($zero);
var_dump($one);
printf("char: %s, ord: %d, byte: %08b\n", $zero, ord($zero), $zero);
printf("char: %s, ord: %d, byte: %08b\n", $one, ord($one), $one);
// string(1) "0"
// string(1) "1"
// char: 0, ord: 48, byte: 00000000
// char: 1, ord: 49, byte: 00000001
$zero = (int)'0';
$one = (int)'1';
var_dump($zero);
var_dump($one);
printf("char: %s, ord: %d, byte: %08b\n", $zero, ord($zero), $zero);
printf("char: %s, ord: %d, byte: %08b\n", $one, ord($one), $one);
// int(0)
// int(1)
// char: 0, ord: 48, byte: 00000000
// char: 1, ord: 49, byte: 00000001
$zero = unpack('C', (string)'0');
$zero = array_pop($zero);
$one = unpack('C', (string)'1');
$one = array_pop($one);
var_dump($zero);
var_dump($one);
printf("char: %s, ord: %d, byte: %08b\n", $zero, ord($zero), $zero);
printf("char: %s, ord: %d, byte: %08b\n", $one, ord($one), $one);
// int(48)
// int(49)
// char: 48, ord: 52, byte: 00110000
// char: 49, ord: 52, byte: 00110001
?>
</pre>
--------------------------------------------------
Dante
attached mail follows:
> Are you sure you are evaluating your binary
> '00000000' properly as you claim? Send a sample code
alrightey then. the binary data itself is actually stored in a mysql
table. (mysql 5.1.9) the relevant part is the following column:
+------------+-----------------
| Field | Type
+------------+-----------------
| bit_string | bit(8)
+------------+-----------------
but of course there are others. assuming there weren't however, data
would be inserted into this table with a queries similar to:
INSERT INTO blah SET bit_string=b'00000001';
INSERT INTO blah SET bit_string=b'00000011';
INSERT INTO blah SET bit_string=b'00000100';
this part appears to work great. i just discovered the bit type in
mysql myself and have been having great fun with it. just in case you
hadn't heard of it reference here: (*please* don't be insulted if this
is old news to you)
http://dev.mysql.com/doc/refman/5.1/en/bit-field-values.html
anyway, when this data is selected from the table the characters are
clearly being represented correctly, they show up unprintable in various
wierd ways and return correct values for bitwise operations. the
problem happens when you try to say:
<?php
// assume this code is part of a method of a greater class that has a
member database handle already initialized...
--- snip ---
$bit_strings = array();
$rh = $this->_dbh->query('SELECT bit_string FROM blah');
if($rh !== false && $rh->num_rows) {
while($bit_string = $rh->fetch_assoc()) {
$bit_strings[] = $bit_string;
}
$rh->free();
}
return $bit_strings;
--- snip ---
// ok so lets say you call this method and just for simplicity sake (no
its really not anywhere near this simple) *know* that the three values
above are the only things that get returned. lets say we know that we
will have an array of three values, which are the binary 1, binary 3,
and binary 4, we inserted above, in that order. in that case the
following check:
if($bit_strings[0] & $bit_strings[1]) {
// blah
}
//evaluates to a binary 1 and is therefore true, as would be expected,
but this check:
if($bit_strings[0] & $bit_strings[2]) {
// blah
}
// evaluates to a binary zero but STILL counts as true! (go ahead, try
it yourself)
?>
Now two things are worth stating here. First is that its comforting to
see unpack('C',... in your sample code, because my fix for the problem
last night eventually turned out to be:
$bits = array_pop(unpack('C', ($bit_string_one & $bit_string_two)));
settype($bits, 'integer');
if($bits) {
return true;
}
... and though it seemed to work the way i wanted i was previously
unfamiliar with unpack/pack and was worried i was approaching this
entirely in the wrong way. Thank you for that.
The second thing that needs to be said here is simply a re-statement of
the original, this time more verbosely. The list of things in php that
evaluate as false is as follows:
* the boolean FALSE itself
* the integer 0 (zero)
* the float 0.0 (zero)
* the empty string, and the string "0"
* an array with zero elements
* an object with zero member variables (PHP 4 only)
* the special type NULL (including unset variables)
* SimpleXML objects created from empty tags
now, all i'm saying is that if, of all ungodly things, the literal
string "0" and empty arrays evaluate to false, isn't it appropriate to
expect a binary zero to evaluate to false as well? Maybe i still don't
get it. :(
thanks btw, for your time.
attached mail follows:
Jon wrote:
> The second thing that needs to be said here is simply a re-statement
> of the original, this time more verbosely. The list of things in php
> that evaluate as false is as follows:
>
> * the boolean FALSE itself
> * the integer 0 (zero)
> * the float 0.0 (zero)
> * the empty string, and the string "0"
> * an array with zero elements
> * an object with zero member variables (PHP 4 only)
> * the special type NULL (including unset variables)
> * SimpleXML objects created from empty tags
>
> now, all i'm saying is that if, of all ungodly things, the literal
> string "0" and empty arrays evaluate to false, isn't it appropriate to
> expect a binary zero to evaluate to false as well? Maybe i still
> don't get it. :(
Jon,
You are correct about the behavior you are observing, sorry I doubted
your ability/methods. Here is a much shorter example of what you are
trying to do:
<?php
// start with int '0'
$as_int = (int) 0x0;
var_dump($as_int);
// convert into to binary string
$as_binstr = (string) pack('C', $as_int);
var_dump($as_binstr);
// cast binary string as boolean
$as_bool = (boolean) $as_binstr;
var_dump($as_bool);
?>
// int(0)
// string(1) "!~unprintable~!"
// bool(true)
You want to know WHY a single byte of all 8 bits set to '0' does not
evaluate as FALSE. I don't know the answer, but my theory is as follows:
Perhaps binary strings are not a normal everyday kind of string. If you
have a binary string, you probably got it from a binary place like a
file or stream. If you read a file and that file contains one byte and
that byte is all 00000000, then how is that FALSE when you got 1 byte
not 0 bytes. I might believe that a binary string should always be TRUE
if the length is greater than ZERO bytes in length. Since binary files
are not meant to be looked at, perhaps length is all that determines
their truth?
Oddly, if you start with this in the example above:
$as_int = (int) 48;
Then, the is_bool will be false! Ok, now I'm with you about odd
behavior and wanting a better answer ;-) You can't really use the
bitwise operators on your binary string either. From the manual:
"Bitwise operators allow you to turn specific bits within an integer
on or
off. If both the left- and right-hand parameters are strings, the
bitwise
operator will operate on the characters' ASCII values."
I think the best bet would be to unpack the binary string into a format
that PHP will play nicely with. Most likely if you are looking at a
single byte, unpacking as an int is the way to go.
Dante
attached mail follows:
Hi all,
I am using php 4.3.2 and mysql , linux.
I have a sql statement below :
UPDATE tbl_chassis_temp SET country = 'Singapore', city
'SINGAPORE', building = 'Tampines Central 6', other = 'Level 03-40',
I need to remove the last comma from sql text above.
I have tried using substr and rtrim , without any success ?
Anyone have any suggestion ?
THanks
- weetat
attached mail follows:
weetat wrote:
> Hi all,
>
> I am using php 4.3.2 and mysql , linux.
>
> I have a sql statement below :
>
> UPDATE tbl_chassis_temp SET country = 'Singapore', city
> 'SINGAPORE', building = 'Tampines Central 6', other = 'Level 03-40',
>
> I need to remove the last comma from sql text above.
> I have tried using substr and rtrim , without any success ?
> Anyone have any suggestion ?
http://us2.php.net/manual/en/function.trim.php
trim: 4.1.0 The optional charlist parameter was added.
$str = "UPDATE tbl_chassis_temp SET country = 'Singapore', city
'SINGAPORE', building = 'Tampines Central 6', other = 'Level 03-40', ";
$str = trim($str, ', ');
print $str;
Dante
attached mail follows:
weetat wrote:
> Hi all,
>
> I am using php 4.3.2 and mysql , linux.
>
> I have a sql statement below :
>
> UPDATE tbl_chassis_temp SET country = 'Singapore', city
> 'SINGAPORE', building = 'Tampines Central 6', other = 'Level 03-40',
>
> I need to remove the last comma from sql text above.
> I have tried using substr and rtrim , without any success ?
> Anyone have any suggestion ?
How about:
$query = substr(trim($query), 0, -1);
?
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
can php do transfer file betwen 2 server without using ftp function socket that use ftp port
Send instant messages to your online friends http://uk.messenger.yahoo.com
attached mail follows:
Hi All!
I've a MySQL table:
table (id INT NOT NULL AUTO_INCREMENT,
flag TINYINT NOT NULL,
msgID VARCHAR(30) NOT NULL,
msgName VARCHAR(30),
size INT NOT NULL,
PRIMARY KEY(id));
If I delete a row, say 5th, the id entries are 1 2 3 4 6 7 ... 10.
I wish to keep entries consecutive, that is rearrange the table as 1 2 3 4 5
6 ... 9. How do I go about it?
Thanks & Regards,
Antonio
attached mail follows:
Antonio Bassinger wrote:
> Hi All!
>
> I've a MySQL table:
>
> table (id INT NOT NULL AUTO_INCREMENT,
> flag TINYINT NOT NULL,
> msgID VARCHAR(30) NOT NULL,
> msgName VARCHAR(30),
> size INT NOT NULL,
> PRIMARY KEY(id));
>
>
> If I delete a row, say 5th, the id entries are 1 2 3 4 6 7 ... 10.
>
> I wish to keep entries consecutive, that is rearrange the table as 1 2 3
> 4 5
> 6 ... 9. How do I go about it?
Read this thread:
http://marc.theaimsgroup.com/?l=php-general&m=114656385709968&w=2
It will tell you this is a really bad idea.
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
On Thursday 08 June 2006 23:58, Antonio Bassinger wrote:
> Hi All!
>
> I've a MySQL table:
>
> table (id INT NOT NULL AUTO_INCREMENT,
> flag TINYINT NOT NULL,
> msgID VARCHAR(30) NOT NULL,
> msgName VARCHAR(30),
> size INT NOT NULL,
> PRIMARY KEY(id));
>
>
> If I delete a row, say 5th, the id entries are 1 2 3 4 6 7 ... 10.
>
> I wish to keep entries consecutive, that is rearrange the table as 1 2 3 4
> 5 6 ... 9. How do I go about it?
>
> Thanks & Regards,
> Antonio
Simple. Don't.
The whole point of having a numeric primary key is that it is both unique and
constant. If you change the primary key, then you have to change every
reference to it in every other table as well. You've just defeated the
purpose of having a non-user-viewable primary key in the first place. You
may as well just use the msgName field, save yourself a column in the
database, and still have a huge problem with data integrity.
As I said, don't do it. Stick with the numeric ID and don't change it. You
gain nothing by re-naming your entire database.
--
Larry Garfield AIM: LOLG42
larry
garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
attached mail follows:
PHP List,
I have a database of about 120 users. Each weak I send out a newsletter.
So far as I know, it's been working fine for the last couple of years.
Then recently some users emailed me to let me know that they haven't
been receiving all the messages. I added extra output to my script to
echo out the name of each member that got an email sent to them, and I
can now see that only about 50 of them are getting the email.
The only think that has changed that I can think of is that I've
upgraded to MySQL 5.0. However, given the type of problem I'm having, I
don't think it's a MySQL problem, it appears much more likely to be a
problem with my PHP code.
This is the script that sends out the message (edited slightly to take
out irrelevant bits of newsletter content):
- - - -
$count = 0;
while ( $member = mysql_fetch_row($result) )
{
set_time_limit(0);
$subject = "Newsletter subject line";
$mailcontent = "This message was sent to " . $member[0] . " at {$member[1]}
Blah, blah, blah - newsletter content goes here.";
mail($member[1], $subject, $mailcontent, $fromaddress);
$count++;
echo "<p>Newsletter sent to " . $member[0] . " at " . $member[1] . "</p>";
}
echo "<p>A total of " .$count ." emails were sent out.</p>\n";
- - - -
The script actually dies before it gets to the last echo which echoes
the value of $count. It outputs about 50 lines of "Newsletter sent to
usersname at name
email.com" and then the cursor is stuck in hourglass
mode and the browser is continually waiting a response. It stays like
that indefinitely, and the only way it stops is if I go to another page
or shut down the browser.
I have heard that the mail() function does have limitations on how many
emails it sends out. But I thought it took hundreds, somewhere between
500 and a thousand, of individual emails before it would die. And I also
thought the set_time_limit(0) function would alleviate the problem of
timing out.
Where have I gone wrong with this?
Any advice would be greatly appreciated. Thank you for taking the time
to read this.
--
Dave M G
attached mail follows:
Dave M G wrote:
> PHP List,
>
> I have a database of about 120 users. Each weak I send out a newsletter.
> So far as I know, it's been working fine for the last couple of years.
>
> Then recently some users emailed me to let me know that they haven't
> been receiving all the messages. I added extra output to my script to
> echo out the name of each member that got an email sent to them, and I
> can now see that only about 50 of them are getting the email.
>
> The only think that has changed that I can think of is that I've
> upgraded to MySQL 5.0. However, given the type of problem I'm having, I
> don't think it's a MySQL problem, it appears much more likely to be a
> problem with my PHP code.
>
> This is the script that sends out the message (edited slightly to take
> out irrelevant bits of newsletter content):
>
> - - - -
> $count = 0;
> while ( $member = mysql_fetch_row($result) )
> {
> set_time_limit(0);
> $subject = "Newsletter subject line";
> $mailcontent = "This message was sent to " . $member[0] . " at {$member[1]}
> Blah, blah, blah - newsletter content goes here.";
> mail($member[1], $subject, $mailcontent, $fromaddress);
> $count++;
> echo "<p>Newsletter sent to " . $member[0] . " at " . $member[1] . "</p>";
> }
> echo "<p>A total of " .$count ." emails were sent out.</p>\n";
> - - - -
>
> The script actually dies before it gets to the last echo which echoes
> the value of $count. It outputs about 50 lines of "Newsletter sent to
> usersname at name
email.com" and then the cursor is stuck in hourglass
> mode and the browser is continually waiting a response. It stays like
> that indefinitely, and the only way it stops is if I go to another page
> or shut down the browser.
>
> I have heard that the mail() function does have limitations on how many
> emails it sends out. But I thought it took hundreds, somewhere between
> 500 and a thousand, of individual emails before it would die. And I also
> thought the set_time_limit(0) function would alleviate the problem of
> timing out.
Ask your host if they have enabled email throttling. If you're sending
out too quickly, they might be getting cut off by your host and you'll
need to sleep() between each email being sent.
--
Postgresql & php tutorials
http://www.designmagick.com/
attached mail follows:
Is there any easy way to "trim" or pick out the none decimal values in a
numric value? Like:
1,333 = 1
5,667 = 5
12,145 = 12
15,997 = 15
Thanks // Jonas
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]