[PHP] Cron php & refresh

2008-04-20 Thread Jeffrey
I'm working on an application that includes e-mail notifications of 
certain events. Because the application will have hundreds or thousands 
of users, I've designed it so that e-mail notifications are saved to a 
MySQL table. Then a regular cron job runs a php page to select the data 
from the table, put it into a mail() command and mail.


My original vision was to have the script do about 50 mails, then pause 
for a 5 seconds, do a meta refresh and run through another 50 and so on 
- with experimentation in numbers as necessary. This process was set up 
because I recall reading somewhere - perhaps the manual - that it is not 
a good thing to run too many php mail()s in succession. Also, I worry 
about php time-outs.


If you know more about PHP and 'nix than I do, you already realise the 
fatal flaw here: meta refresh doesn't work on a cron job.


Question: is there an alternative? I appreciate I could use sleep() 
after every 50 mails - but there would still be the time-out problem.


I've searched the manual and via Google - but haven't found anything - 
possibly I am searching on the wrong terms.


Your help will be much appreciated.

Thanks,

Jeffrey

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



Re: [PHP] Cron php & refresh

2008-04-20 Thread Per Jessen
Jeffrey wrote:

> I'm working on an application that includes e-mail notifications of
> certain events. Because the application will have hundreds or
> thousands of users, I've designed it so that e-mail notifications are
> saved to a MySQL table. Then a regular cron job runs a php page to
> select the data from the table, put it into a mail() command and mail.

Why not just send the notification at the time of the event?  (I assume
you update the database at the time of the event).


/Per Jessen, Zürich


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



Re: [PHP] PHP console script vs C/C++/C#

2008-04-20 Thread Per Jessen
Nathan Nobbe wrote:

> umm, so whats going on here is the implicit component of the statement
> that incorporates relative or absolute performance.  in terms of
> relative performance the statement is accurate; in terms of absolute
> performance, its quite inaccurate.
> 

Nathan, I think we're disagreeing about the meaning of "algorithm" - an
algorithm does not have an absolute performance until it's been
implemented - in some of other language and machine. 



/Per Jessen, Zürich


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



Re: [PHP] Cron php & refresh

2008-04-20 Thread Børge Holen
On Sunday 20 April 2008 11:27:38 Jeffrey wrote:
> I'm working on an application that includes e-mail notifications of
> certain events. Because the application will have hundreds or thousands
> of users, I've designed it so that e-mail notifications are saved to a
> MySQL table. Then a regular cron job runs a php page to select the data
> from the table, put it into a mail() command and mail.
>
> My original vision was to have the script do about 50 mails, then pause
> for a 5 seconds, do a meta refresh and run through another 50 and so on
> - with experimentation in numbers as necessary. This process was set up
> because I recall reading somewhere - perhaps the manual - that it is not
> a good thing to run too many php mail()s in succession. Also, I worry
> about php time-outs.
>
> If you know more about PHP and 'nix than I do, you already realise the
> fatal flaw here: meta refresh doesn't work on a cron job.
>
> Question: is there an alternative? I appreciate I could use sleep()
> after every 50 mails - but there would still be the time-out problem.
>
> I've searched the manual and via Google - but haven't found anything -
> possibly I am searching on the wrong terms.
>
> Your help will be much appreciated.
>
> Thanks,
>
> Jeffrey

What a waste. Is the MTA operational on the server? if so, forget mailing with 
php and rather use php to access the mta. It is designed to actually send 
mails, lots of lots of em. If not, set it up.
I recon a cluster with hundreds of thousands of users ought to have such a 
thing... a couple of blades or some of those solaris niagara 8 core nicies 
doing it.


-- 
---
Børge Holen
http://www.arivene.net

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



Re: [PHP] Cron php & refresh

2008-04-20 Thread Jeffrey

Per Jessen wrote:

Jeffrey wrote:


I'm working on an application that includes e-mail notifications of
certain events. Because the application will have hundreds or
thousands of users, I've designed it so that e-mail notifications are
saved to a MySQL table. Then a regular cron job runs a php page to
select the data from the table, put it into a mail() command and mail.


Why not just send the notification at the time of the event?  (I assume
you update the database at the time of the event).


/Per Jessen, Zürich


Because in my experience, several hundred e-mails takes time to send, 
hence either the user leaves the page before all the mails are sent or 
the page times out before all mails are sent. And if there are thousands 
of e-mails, it will only get worse.


Jeffrey


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



Re: [PHP] Cron php & refresh

2008-04-20 Thread Per Jessen
Jeffrey wrote:

> Per Jessen wrote:
>> Jeffrey wrote:
>> 
>>> I'm working on an application that includes e-mail notifications of
>>> certain events. Because the application will have hundreds or
>>> thousands of users, I've designed it so that e-mail notifications
>>> are saved to a MySQL table. Then a regular cron job runs a php page
>>> to select the data from the table, put it into a mail() command and
>>> mail.
>> 
>> Why not just send the notification at the time of the event?  (I
>> assume you update the database at the time of the event).
>> 
>> 
>> /Per Jessen, Zürich
>> 
>> 
> Because in my experience, several hundred e-mails takes time to send,
> hence either the user leaves the page before all the mails are sent or
> the page times out before all mails are sent. And if there are
> thousands of e-mails, it will only get worse.

Sorry, I (wrongly) assumed 1 event = 1 email. 

OK, then I'd stick to what you're doing - add the event to a queue (i.e.
your database), and poll this at regular intervals.  I don't think you
need to worry about the number of emails sent per interval.  Just let
your PHP script generate the sendmail commands and the email-text to
stdout, then pipe that to /bin/sh. 

The output generated by your script would look like this:
sendmail -oi -r   .  <  .  

Re: [PHP] Cron php & refresh

2008-04-20 Thread Per Jessen
Børge Holen wrote:

> Is the MTA operational on the server? if so, forget
> mailing with php and rather use php to access the mta. 

Yeah, that is what mail() does - it calls sendmail. 


/Per Jessen, Zürich


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



[PHP] Check RAW data

2008-04-20 Thread rb
I'm getting from an external source a PNG image in raw format (encoded in 
base64).


And with this code I'll echo on the screen.

--
$img=base64_decode($_POST['img']);

header("Content-type: image/png");
echo $img;
--

How can I check if the data received is a real PNG raw (and not malicious 
code) ? 



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



Re: [PHP] Check RAW data

2008-04-20 Thread Jason Norwood-Young
On Sun, 2008-04-20 at 15:52 +0200, rb wrote:
> I'm getting from an external source a PNG image in raw format (encoded in 
> base64).
> 
> And with this code I'll echo on the screen.
> 
> --
> $img=base64_decode($_POST['img']);
> 
> header("Content-type: image/png");
> echo $img;
> --

A quick way would be to try and make an image with the GD library.
Something like:
if (imagecreatefromstring($img)) {
header("Content-type:image/png");
echo $img;
}



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



Re: [PHP] Check RAW data

2008-04-20 Thread Regular email

On Sun, 2008-04-20 at 15:52 +0200, rb wrote:
I'm getting from an external source a PNG image in raw format (encoded in 
base64).


And with this code I'll echo on the screen.

--
$img=base64_decode($_POST['img']);

header("Content-type: image/png");
echo $img;
--


A quick way would be to try and make an image with the GD library.
Something like:
if (imagecreatefromstring($img)) {
header("Content-type:image/png");
echo $img;
}


Perhaps check the image header matches the correct format for a PNG image.

--
Richard Heyes

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++



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



Re: [PHP] Alter Table newbie help needed ...

2008-04-20 Thread revDAVE
On 4/19/2008 2:37 PM, "Jason Norwood-Young" <[EMAIL PROTECTED]>
wrote:

> Might be obvious but you are doing "mysql_query($sql);", right?

Hello Jason,

Thanks - Your idea worked well -  for a while - but then I ran into
trouble...

 I added : mysql_error() and it said:


Table 'connect2.ztest' doesn't exist

- so I guess it was not knowing to use the 'try1' connection ( try1.ztest) -
(connect2 was some other one I set up for something else)

I'm using Dreamweaver cs3 - maybe it's confused?

Q: Is there a way to insure that it uses the right connection ( try1 - not
connect2 )?


BTW: I tried `try1.ztest` but it didn't like that:

$sql = 'ALTER TABLE `try1.ztest` ADD `myfield2` VARCHAR(10) NOT NULL;';


--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists]




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



Re: [PHP] Alter Table newbie help needed ...

2008-04-20 Thread David Giragosian
On 4/20/08, revDAVE <[EMAIL PROTECTED]> wrote:
>
> On 4/19/2008 2:37 PM, "Jason Norwood-Young" <[EMAIL PROTECTED]>
> wrote:
>
> > Might be obvious but you are doing "mysql_query($sql);", right?
>
> Hello Jason,
>
> Thanks - Your idea worked well -  for a while - but then I ran into
> trouble...
>
> I added : mysql_error() and it said:
>
>
> Table 'connect2.ztest' doesn't exist
>
> - so I guess it was not knowing to use the 'try1' connection ( try1.ztest)
> -
> (connect2 was some other one I set up for something else)
>
> I'm using Dreamweaver cs3 - maybe it's confused?
>
> Q: Is there a way to insure that it uses the right connection ( try1 - not
> connect2 )?
>
>
> BTW: I tried `try1.ztest` but it didn't like that:
>
> $sql = 'ALTER TABLE `try1.ztest` ADD `myfield2` VARCHAR(10) NOT NULL;';


Is try1 the name of a database? The SQL syntax is
databasename.tablename.fieldname.

When you issue a query using mysql_query() you can explicitly indicate the
connection (returned by mysql_connect()) to use as the second parameter,
e.g., mysql_query($sql_Statement, $returnedConnectionObject);

HTH,

David


Re: [PHP] PHP console script vs C/C++/C#

2008-04-20 Thread Nathan Nobbe
On Sun, Apr 20, 2008 at 6:50 AM, Per Jessen <[EMAIL PROTECTED]> wrote:

> Nathan Nobbe wrote:
>
> > umm, so whats going on here is the implicit component of the statement
> > that incorporates relative or absolute performance.  in terms of
> > relative performance the statement is accurate; in terms of absolute
> > performance, its quite inaccurate.
> >
>
> Nathan, I think we're disagreeing about the meaning of "algorithm" - an
> algorithm does not have an absolute performance until it's been
> implemented - in some of other language and machine.
>

i thought about that too..  i looked it up on wikipedia before i posted just
to be sure of myself.  the way i view it, there are 2 things an algorithm
could mean.  there are for instance well known algorithms like bubble sort
or quick sort, but basically any function written in any language is an
algorithm.  and wikipedia agrees w/ that statement.
but either way i dont see why it matters, if you implement an algorithm
(according to you) in c or php then at that point it will have an absolute
performance.  and the likelihood its faster in c, absolutely, is very very
high :)

-nathan


Re: [PHP] Cron php & refresh

2008-04-20 Thread Larry Garfield
On Sunday 20 April 2008, Jeffrey wrote:
> I'm working on an application that includes e-mail notifications of
> certain events. Because the application will have hundreds or thousands
> of users, I've designed it so that e-mail notifications are saved to a
> MySQL table. Then a regular cron job runs a php page to select the data
> from the table, put it into a mail() command and mail.
>
> My original vision was to have the script do about 50 mails, then pause
> for a 5 seconds, do a meta refresh and run through another 50 and so on
> - with experimentation in numbers as necessary. This process was set up
> because I recall reading somewhere - perhaps the manual - that it is not
> a good thing to run too many php mail()s in succession. Also, I worry
> about php time-outs.
>
> If you know more about PHP and 'nix than I do, you already realise the
> fatal flaw here: meta refresh doesn't work on a cron job.
>
> Question: is there an alternative? I appreciate I could use sleep()
> after every 50 mails - but there would still be the time-out problem.
>
> I've searched the manual and via Google - but haven't found anything -
> possibly I am searching on the wrong terms.
>
> Your help will be much appreciated.

Why not just have the cron task itself run every 5 minutes?  Every 5  minutes, 
hit a PHP script that will pull the next 50 messages to send and send them, 
then exit.  In 5 minutes minus the time that takes, cron will fire your 
script again.  Problem solved.  

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   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

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



Re: [PHP] PHP console script vs C/C++/C#

2008-04-20 Thread Robert Cummings

On Sun, 2008-04-20 at 14:17 -0400, Nathan Nobbe wrote:
> On Sun, Apr 20, 2008 at 6:50 AM, Per Jessen <[EMAIL PROTECTED]> wrote:
> 
> > Nathan Nobbe wrote:
> >
> > > umm, so whats going on here is the implicit component of the statement
> > > that incorporates relative or absolute performance.  in terms of
> > > relative performance the statement is accurate; in terms of absolute
> > > performance, its quite inaccurate.
> > >
> >
> > Nathan, I think we're disagreeing about the meaning of "algorithm" - an
> > algorithm does not have an absolute performance until it's been
> > implemented - in some of other language and machine.
> >
> 
> i thought about that too..  i looked it up on wikipedia before i posted just
> to be sure of myself.  the way i view it, there are 2 things an algorithm
> could mean.  there are for instance well known algorithms like bubble sort
> or quick sort, but basically any function written in any language is an
> algorithm.  and wikipedia agrees w/ that statement.

"Algorithm" is just a fancy word for recipe. In fact, you should ask a
someone sometime what algorithm they're using to bake a cake ;)

> but either way i dont see why it matters, if you implement an algorithm
> (according to you) in c or php then at that point it will have an absolute
> performance.  and the likelihood its faster in c, absolutely, is very very
> high :)

If something written in C is slower than something in PHP, or slower
even than something written in C++, then it's a problem with the
implementation, not the language. The best C++ can do is match the speed
of C. C++ has overhead, that overhead can't be squashed to be more
efficient than C, it can only be removed when not necessary. Unless of
course, for some odd, odd, odd reason, an optimization for C++ compiled
code was not also added to C. Since any optimization that can make C++
faster can also make C faster where appropriate. The same is true of
memory consumption in C++ versus C.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] PHP console script vs C/C++/C#

2008-04-20 Thread Nathan Nobbe
On Sun, Apr 20, 2008 at 2:34 PM, Robert Cummings <[EMAIL PROTECTED]>
wrote:

>
> On Sun, 2008-04-20 at 14:17 -0400, Nathan Nobbe wrote:
> > On Sun, Apr 20, 2008 at 6:50 AM, Per Jessen <[EMAIL PROTECTED]> wrote:
> >
> > > Nathan Nobbe wrote:
> > >
> > > > umm, so whats going on here is the implicit component of the
> statement
> > > > that incorporates relative or absolute performance.  in terms of
> > > > relative performance the statement is accurate; in terms of absolute
> > > > performance, its quite inaccurate.
> > > >
> > >
> > > Nathan, I think we're disagreeing about the meaning of "algorithm" -
> an
> > > algorithm does not have an absolute performance until it's been
> > > implemented - in some of other language and machine.
> > >
> >
> > i thought about that too..  i looked it up on wikipedia before i posted
> just
> > to be sure of myself.  the way i view it, there are 2 things an
> algorithm
> > could mean.  there are for instance well known algorithms like bubble
> sort
> > or quick sort, but basically any function written in any language is an
> > algorithm.  and wikipedia agrees w/ that statement.
>
> "Algorithm" is just a fancy word for recipe. In fact, you should ask a
> someone sometime what algorithm they're using to bake a cake ;)


great, so you agree, and my previous posts are right.


> > (according to you) in c or php then at that point it will have an
> absolute
> > performance.  and the likelihood its faster in c, absolutely, is very
> very
> > high :)
>
> > but either way i dont see why it matters, if you implement an algorithm
>
> If something written in C is slower than something in PHP, or slower
> even than something written in C++, then it's a problem with the
> implementation, not the language. The best C++ can do is match the speed
> of C. C++ has overhead, that overhead can't be squashed to be more
> efficient than C, it can only be removed when not necessary. Unless of
> course, for some odd, odd, odd reason, an optimization for C++ compiled
> code was not also added to C. Since any optimization that can make C++
> faster can also make C faster where appropriate. The same is true of
> memory consumption in C++ versus C.
>

ya; conceptually c should always be faster than c++, for the same reason c
should be faster than php.  i think the compiler optimizations is why c++ is
currently listed as 'faster' on the great computer language shootout, but i
havent looked at the tests.

-nathan


[PHP] Opening a new window from Header Location or any other way

2008-04-20 Thread Richard Kurth

I have my login.php file that when I access the login fields they are in
a small window width=400,height=250. When I click on submit I what it to
close this window and open another full window with the web page that
the script directs it to. But nomater what I do it opens it in the same
window which is to small. Is there anyway to make it open the window up
or close it and open another full window. I know PHP is server side and
it does not have control of the client.

Of course this does not work. Is there a way to do this in javascript or
something else.
$link = "http://www.domain.com/main.php target=\"_blank\"";
   header("Location:$link");
   ob_end_flush();
   exit;



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



Re: [PHP] PHP console script vs C/C++/C#

2008-04-20 Thread Robert Cummings

On Sun, 2008-04-20 at 14:41 -0400, Nathan Nobbe wrote:
> On Sun, Apr 20, 2008 at 2:34 PM, Robert Cummings <[EMAIL PROTECTED]>
> wrote:
> 
> >
> > On Sun, 2008-04-20 at 14:17 -0400, Nathan Nobbe wrote:
> > > On Sun, Apr 20, 2008 at 6:50 AM, Per Jessen <[EMAIL PROTECTED]> wrote:
> > >
> > > > Nathan Nobbe wrote:
> > > >
> > > > > umm, so whats going on here is the implicit component of the
> > statement
> > > > > that incorporates relative or absolute performance.  in terms of
> > > > > relative performance the statement is accurate; in terms of absolute
> > > > > performance, its quite inaccurate.
> > > > >
> > > >
> > > > Nathan, I think we're disagreeing about the meaning of "algorithm" -
> > an
> > > > algorithm does not have an absolute performance until it's been
> > > > implemented - in some of other language and machine.
> > > >
> > >
> > > i thought about that too..  i looked it up on wikipedia before i posted
> > just
> > > to be sure of myself.  the way i view it, there are 2 things an
> > algorithm
> > > could mean.  there are for instance well known algorithms like bubble
> > sort
> > > or quick sort, but basically any function written in any language is an
> > > algorithm.  and wikipedia agrees w/ that statement.
> >
> > "Algorithm" is just a fancy word for recipe. In fact, you should ask a
> > someone sometime what algorithm they're using to bake a cake ;)
> 
> 
> great, so you agree, and my previous posts are right.

I'm not going to agree with a blanket statement like that *lol* and I
don't feel like going back to check for specific examples of
incorrectness. This isn't U.S. politics... you don't get to add riders.

> > > (according to you) in c or php then at that point it will have an
> > absolute
> > > performance.  and the likelihood its faster in c, absolutely, is very
> > very
> > > high :)
> >
> > > but either way i dont see why it matters, if you implement an algorithm
> >
> > If something written in C is slower than something in PHP, or slower
> > even than something written in C++, then it's a problem with the
> > implementation, not the language. The best C++ can do is match the speed
> > of C. C++ has overhead, that overhead can't be squashed to be more
> > efficient than C, it can only be removed when not necessary. Unless of
> > course, for some odd, odd, odd reason, an optimization for C++ compiled
> > code was not also added to C. Since any optimization that can make C++
> > faster can also make C faster where appropriate. The same is true of
> > memory consumption in C++ versus C.
> >
> 
> ya; conceptually c should always be faster than c++, for the same reason c
> should be faster than php.  i think the compiler optimizations is why c++ is
> currently listed as 'faster' on the great computer language shootout, but i
> havent looked at the tests.

No, no, no... C should not always be faster than C++, not even
conceptually. Only C++ should never be faster than C. In other words
(and in a perfect world):

C <= C++  (with respect to speed/memory)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Check RAW data

2008-04-20 Thread Richard Heyes

I don't believe malicious code can be executed with echo and header.


The header of the PNG file, not a HTTP header.

--
Richard Heyes

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++


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



Re: [PHP] Check RAW data

2008-04-20 Thread Richard Heyes

I mean, if you already specified it as a PNG image with header(), how
do you execute Javascript/malicious code, as the browser will render
it as a PNG?


Malicious code can still be embedded in images. The vulnerabilities ISTR 
are in Windows image handling libraries. I assume they've been fixed now 
though because it was some time ago. But that doesn't mean to say more 
won't be found.


--
Richard Heyes

++
| Access SSH with a Windows mapped drive |
|http://www.phpguru.org/sftpdrive|
++

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



Re: [PHP] Cron php & refresh

2008-04-20 Thread Jason Norwood-Young

On Sun, 2008-04-20 at 13:32 -0500, Larry Garfield wrote:
> On Sunday 20 April 2008, Jeffrey wrote:
> > I'm working on an application that includes e-mail notifications of
> > certain events. Because the application will have hundreds or thousands
> > of users, I've designed it so that e-mail notifications are saved to a
> > MySQL table. Then a regular cron job runs a php page to select the data
> > from the table, put it into a mail() command and mail.
> >
> > My original vision was to have the script do about 50 mails, then pause
> > for a 5 seconds, do a meta refresh and run through another 50 and so on
> > - with experimentation in numbers as necessary. This process was set up
> > because I recall reading somewhere - perhaps the manual - that it is not
> > a good thing to run too many php mail()s in succession. Also, I worry
> > about php time-outs.
> >
> > If you know more about PHP and 'nix than I do, you already realise the
> > fatal flaw here: meta refresh doesn't work on a cron job.
> >
> > Question: is there an alternative? I appreciate I could use sleep()
> > after every 50 mails - but there would still be the time-out problem.
> >
> > I've searched the manual and via Google - but haven't found anything -
> > possibly I am searching on the wrong terms.
> >
> > Your help will be much appreciated.
> 
> Why not just have the cron task itself run every 5 minutes?  Every 5  
> minutes, 
> hit a PHP script that will pull the next 50 messages to send and send them, 
> then exit.  In 5 minutes minus the time that takes, cron will fire your 
> script again.  Problem solved.  

If you take this approach, just make sure you build a proper queuing
system or mark the mails you're processing as being processed in the DB.
Otherwise you could end up with a situation where the system takes
longer than 5 minutes to process the mails (it shouldn't, but you never
know - maybe there's a rogue process or the mail queue is backed up or
something) and then the PHP script starts at the beginning of those 50
mails again. It's an obvious error, but I've done it in an app where I
thought "There's no way the process won't finish before the next cron
job starts", and then it happened and I ended up sending a couple
thousand SMS's out twice at cost to my client. Oops.

J


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



Re: [PHP] Cron php & refresh

2008-04-20 Thread Børge Holen
On Sunday 20 April 2008 13:37:04 Per Jessen wrote:
> Børge Holen wrote:
> > Is the MTA operational on the server? if so, forget
> > mailing with php and rather use php to access the mta.
>
> Yeah, that is what mail() does - it calls sendmail.
>
>
> /Per Jessen, Zürich

What the point of 50 mails now and then, let it all be decided by the mta. you 
don't need php to do stuff it isn't intended for.
the mta will send next mail as the previous is accepted and written off as 
sent.

-- 
---
Børge Holen
http://www.arivene.net

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



[PHP] function returns no value

2008-04-20 Thread Ali Reza Sajedi

Hello,

with the following call I try to print a string out of DB

echo $allg->translate($db, $lang, 14, "auth/authCallback", 4);

function translate () should do a DB querry and returns the requested 
string. Although the querry yields a positive result, the function returns 
no value.


Here is the function:

function translate ($db, $lang, $MaiKey, $page, $pid) {

 $statement = "SELECT fa FROM language WHERE MaiKey='$MaiKey' AND 
page='$page' AND pid='$pid'";


 $result = $db->Execute($statement);

 if ($result=== false) die();

 return $result->fields[0];
}

Could anybody see what is going wrong here?

I appreciate any hint.

Ali 



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



Re: [PHP] function returns no value

2008-04-20 Thread Nathan Nobbe
On Sun, Apr 20, 2008 at 4:51 PM, Ali Reza Sajedi <[EMAIL PROTECTED]>
wrote:

> Hello,
>
> with the following call I try to print a string out of DB
>
> echo $allg->translate($db, $lang, 14, "auth/authCallback", 4);
>
> function translate () should do a DB querry and returns the requested
> string. Although the querry yields a positive result, the function returns
> no value.
>
> Here is the function:
>
> function translate ($db, $lang, $MaiKey, $page, $pid) {
>
>  $statement = "SELECT fa FROM language WHERE MaiKey='$MaiKey' AND
> page='$page' AND pid='$pid'";
>
>  $result = $db->Execute($statement);
>
>  if ($result=== false) die();
>
>  return $result->fields[0];
> }
>
> Could anybody see what is going wrong here?


its hard to say, since we cant see whats going on inside the Execute
function...  you might try to add a
var_dump($result);
directly after the call to Execute, just for debugging purposes, then remove
it once you know whats going on.

-nathan


Re: [PHP] function returns no value

2008-04-20 Thread Liran Oz

Can't really know without the rest of the code.
Check if the function really returns and not Dying (Add some messege like: 
die("help me I'm dying");  ).

Also use print_r or something like to see what's inside the fields array.
it is possible that it's an associative array and you are using the wrong 
index (0)


Liran
- Original Message - 
From: "Ali Reza Sajedi" <[EMAIL PROTECTED]>

To: 
Sent: Sunday, April 20, 2008 11:51 PM
Subject: [PHP] function returns no value



Hello,

with the following call I try to print a string out of DB

echo $allg->translate($db, $lang, 14, "auth/authCallback", 4);

function translate () should do a DB querry and returns the requested 
string. Although the querry yields a positive result, the function returns 
no value.


Here is the function:

function translate ($db, $lang, $MaiKey, $page, $pid) {

 $statement = "SELECT fa FROM language WHERE MaiKey='$MaiKey' AND 
page='$page' AND pid='$pid'";


 $result = $db->Execute($statement);

 if ($result=== false) die();

 return $result->fields[0];
}

Could anybody see what is going wrong here?

I appreciate any hint.

Ali

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




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



[PHP] AJAX and PHP

2008-04-20 Thread Alain Roger
Hi,

i'm playing around with AJAX and PHP to create something like a "small
desktop" application.
basically the first step is to log in the system.
for that i have a log-in form where users can choose the interface language.

here is my problem :
when the log-in form runs, it is in English. user can click on some arrow to
open another DIV and display all other languages available.
a click on a particular flag, will call the PHP page where the log-in form
(login field + password field) are stored with dynamic language interface.

however, i make no sense for the title of this form to call a PHP page where
will be just 1 dynamic text (changing on flag choice).
so if you understand well, i have 2 divs (1 for form title, 1 for log-in
form itself). and i load thanks AJAX php code into divs.

my problem is that i do not want to write a PHP page just for 1 label... it
makes sense for a complete form but not for a simple text line or label.

So how can i do that without refreshing page. using AJAX and PHP only ?
i guess you already faced such situation so i would really appreciate your
help.

thanks a lot,

-- 
Alain

Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008