Jump to content

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

Maybe you should clarify better because I am confused as to what you are talking about. However, I did notice that you have a variable you are using as $to but do not see it set anywhere and somewhere else you use $_POST['to']. Is the $to supposed to be $_POST['to']?

Link to comment
https://forums.phpfreaks.com/topic/232121-php-array-problem/#findComment-1194025
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.