tags:

views:

18

answers:

1

I cannot figure out why my array is not working, I have $carrier coming from a text document.The user selects thier carrier, and it is stored in registry.txt. I open it back up, and mail "$number" followed by each carrier's specific address, for example verizon's would be "vtext.com" I would like the array to look at $carrier, and then assign a value. For example, if $carrier = "verizon" , vtext.com. Then, I have the array linked to the mail statement as $number . "@" . $company

$text = fopen("../data/textmembers/registry.txt","r") or die("couldent open file");

  while (!feof($text)) {
$name = fgets($text);
$number = fgets($text);
$carrier = fgets($text);
$date = fgets($text);
$line = fgets($text);



$message .= $content; 
$message .= "\n";
$number = trim($number);


 $company = array(
"Verizon"  => "vtext.com",
"AT&T"     => "txt.att.net",
"T-mobile" => "tmomail.net",
"Sprint"   => "messaging.nextel.com"
 );


 $company [$carrier];



 mail($number . "@" . $company, "SGA Event Alert", $message, "SGA"); 
 Header("Location: mailconf.php");

 }

Thanks a lot for the help!

+2  A: 

You just need to choose the right company.

mail($number . "@" . $company[$carrier], "SGA Event" ...);

Also, don't forget to call die() after header()

nickf
okay, thanks!I am still getting a "undefined index" error, and both my strings match perfectly.. Notice: Undefined index: Verizon in /pass/services/www/clubs/wwwroot/bk/sga/admin/sendmessage.php on line 71 Notice: Undefined index: Verizon in /pass/services/www/clubs/wwwroot/bk/sga/admin/sendmessage.php on line 71Notice: Undefined offset: 0 in /pass/services/www/clubs/wwwroot/bk/sga/admin/sendmessage.php on line 71
Ryan
Make sure there's no extra whitespace characters (spaces, new lines, etc) around it. Try adding this line: `$carrier = trim($carrier);`
nickf