Re: [PHP] looping through a $_POST variable



On Sun, December 30, 2007 5:29 pm, Richard Kurth wrote:
I am trying to loop through a $_POST variable. It comes from a text
area and it will have data like many email address or just one listed
with a space or on a new line. I can't seam to get the data to extract
properly. I have tried this below

$array = explode(' ', $_POST['emails']);

//see what you have.
//maybe it's not hat you think
var_dump($_POST['emails']);


foreach ($array as $value) {

//you should probably validate the emails using:

http://php.net/imap_rfc822_parse_adrlist

$value_sql = mysql_real_escape_string($value);

$sql = "SELECT id FROM contacts where emailaddress = '$value' AND
members_id = '$memberid'";

Use '$value_sql' here.

And I dunno where $memberid came from, but maybe it should be escaped
as well.

$sql_result=safe_query($sql);

I'm not sure what "safe_query" is doing, and maybe you think it can
escape the data you embedded into the SQL, but I don't see how you can
do that... Sort of a Humpty-Dumpty problem...

while ($row=mysql_fetch_array($sql_result)){
$id = $row["id"];
$sql1="UPDATE contacts SET emailstatus ='Unsubscribed' WHERE id =
'$id'";
safe_query($sql1);
}}


--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?
.



Relevant Pages

  • Re: The extra chunk of New Mexico
    ... On Sun, 17 Jun 2007, The Chief Instigator wrote: ... children will be looking for an escape from that somewhere between Lampasas ...
    (misc.transport.road)
  • Re: expecting
    ... > there is no escape by the river ... > the sun is up ... > chuck's nobility again ...
    (rec.arts.poems)
  • Re: Solving the AP CH morning rehearsal outside radios
    ... If you find the right spot you can escape the outside ... just say you were taking a stroll and wanted to get in from the sun ... ... And then the tide comes in and you get blown away. ...
    (rec.music.artists.springsteen)
  • Re: Need some Shade?
    ... the shade for a little while to escape the sun. Well.....I've invented ... Bob, FYI, the links in this post appear in my newsreader on separate ...
    (rec.windsurfing)