Re: Is it safe to do this?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



That depends on what you're doing. Here's why I can't
provide feedback:
   1) Your code isn't at all complete, the foreach
isn't even finished.

Not what matters here, I just snipped a bit of code in
here.  I'm not even concerned about it because the
code works fine.  I just need some work on a query.

   2) Where does the $addresses variable come from and
what are you 
trying todo with it?

Again it's a snipped code.  $addresses collects
information from an emails.  It searches for special
characters only, if no matches it does nothing, if a
match it runs a query.  So looks for matches such as
@, +, _ for email addresses in the original email
sent, minus the headers.

   3) What is the mysql table and its columns supposed
to represent?

What is the mysql table?  I'm not sure what your
asking here.  What's it for?  For my site.  Why do you
need me to explain that?  I think my query explains
what's going on here.  Another person responded to me
about this and new exactly what I was trying to do. 
But for the record it's for a bouncing email script. 
To handle bounced emails, again it's only a bit of
snipped code, the rest is fine.

   4) What is this code supposed to accomplish?

Bounced emails, if an email is bounced it will do a
search and do something if and flag account if it's
bad.  If it finds an email that is not in the DB it
also does nothing.  (spam emails mainly go into that
account)

As for the query.  I want to change a value of a field
when it reaches a certian value.  So was wondering if
it was safe to change a value in one field once it
reaches a set value.

Okay with my program site emails that have a
email_setting of:

0 - All emails go to external inboxes and internal
inboxes
1 - All emails go to external inboxes and not internal
2 - All emails go to internal inboxes and not external

Each user can toggle what they want, ext. is real
email addresses... int. is the internal one with the
account which is not an email just an inbox.

So when it reaches a value of -5 means it's bounced 5
times therefore needs to be set to a lower value so
emails are not sent.

So I have:

field1
field2

field1 - is used for 0 , 1 , 2 value to send emails to
inboxes internal and external.  Anything set in
negative figures no internal or external email will be
sent to that user.

field2 - is used to track the number of times the
email has bounced.  So when it reaches 5 I need to
handle it and reset filed1 to a negative value.

So regarding my first example, it's no longer used by
me and won't go back to it.  But is example 2 going to
work?

...

UPDATE users SET email_setting='-1' WHERE emailerror >
5

...

will that set email_setting to -1 if emailerror has a
value of 5 or more?

J

Jerry wrote:

> Hi,
> 
> Is it safe to do this:
> 
> <snip>
> 
>     foreach ($addresses as $email) {
>         $body = str_replace($email, $comp_uri,
$body);
>    mysql_query ("update users SET email_setting='-1'
> WHERE email='$email'") or die ("Can't set
> email_setting");
>    mysql_query ("UPDATE users SET email_setting='-1'
WHERE emailerror > 5
") or die ("Unable ");
> 
> </snip>
> 
> Or would I be better to do this?:
> 
> <snip>
> 
>     foreach ($addresses as $email) {
>         $body = str_replace($email, $comp_uri,
$body);
>    mysql_query ("update users SET emailerror='+1'
> WHERE email='$email'") or die ("Can't update
> email_setting");
>    mysql_query ("UPDATE users SET email_setting='-1'
> WHERE emailerror > 5") or die ("Unable ");
> 
> </snip>
> 
> Suggestions welcome.
> 
> Jerry
> 
> Find local movie times and trailers on Yahoo!
Movies.
> http://au.movies.yahoo.com


-- 
--
paperCrane <Justin Patrin>



Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux