See the MYSQL_NUM
you have there? That is going to return your data using the column indexes as keys (ie 0, 1, 2, etc).
You must either
a) find out which column index the email
field is and do:
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
// 'email' is in column number 5
$row[5] .='@gmail.com';
for ($i=0; $i<count($row); $i++)
{
$row[$i] = str_replace("\n", " ", $row[$i]);
$row[$i] = str_replace("\r", " ", $row[$i]);
}
}
b) OR you can change MYSQL_NUM
to MYSQL_ASSOC
, and do:
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$row['email'] .='@gmail.com';
foreach($row as &$value)
{
$value = str_replace("\n", " ", $value);
$value = str_replace("\r", " ", $value);
}
}
Note the "&"
before $value
to make it a reference.
I would do the latter (I prefer foreach
to for
:)