Jump to content

PHP Array Problem


Mod-Jay

Recommended Posts

Okay the problem is that it wont find the correct carrier. it dont even find it. i dont know whats wrong. Please take a look at the code. i dont know how to explain it better

 

$carriers = array('verizon'=>'@vtext.com','tmobile'=>'@tomomail.com','sprint'=>'@messaging.sprintpcs.com','att'=>'@txt.att.net','virgin'=>'@vmobl.com','textnow'=>'@textnow.me','metro'=>'@mymetropcs.com','unknown'=>'@teleflip.com');
							if (array_key_exists($carrier, $carriers))
							{
								$correctCarrier = $carriers[$carrier];
								$i = 0;
									While($i < $_POST['amount'])
									{
										$i++;
										$formatted_number = $to.$correctCarrier;
										$result = ("$i of Your Messages Has been sent to the number ". $_POST['to'] . ".<br>" . mail("$formatted_number", "$subject", "$message") . "");
									}
								mysql_query("INSERT INTO `msgssent` (`number`, `numberofmsg`, `subject`, `message`) VALUES ('". $formatted_number ."', '". $i ."', '". $subject ."', '". $message ."')") Or die(mysql_error());
								Echo $result;
							}

Link to comment
https://forums.phpfreaks.com/topic/232121-php-array-problem/
Share on other sites

if (array_key_exists($carrier, $carriers))								
{	
CorrectCarrier = $carriers[$carrier];

 

At the top of your php file you are setting an array in $carriers but your saying array_key_exsist($carrier... so where are you setting your array keys in $carrier, because as it stands now you're basically looking for a key that is NULL in your $carriers array.

 

so maybe this would do it:

 

 $carrier = array_values($carriers);
if (array_key_exists($carrier, $carriers))
{
CorrectCarrier = $carriers[$carrier];

 

I'm still working on array's so this may not be correct but hey I'm giving it a shot!  :P

Link to comment
https://forums.phpfreaks.com/topic/232121-php-array-problem/#findComment-1194020
Share on other sites

Also everytime i send something it leaves a '1' at the end of the message. 1 of Your Messages Has been sent to the number ***.1 , idk why its doing it though

 

Because your concatenating a call to the mail() function onto the end of your $result string and mail() is returning true (1).

Link to comment
https://forums.phpfreaks.com/topic/232121-php-array-problem/#findComment-1194042
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.