Page 2 of 2
Re: send SMS php coding
Posted: Thu Jul 09, 2015 9:10 am
by Celauran
Variables aren't validated inside single quotes, so you're sending $row["monumber"] (ie. the actual string) rather than the value it contains. Try like this:
Code: Select all
$response = sendSMS('47799', '692px', $row["mobnumber"], "{$row['description']} expiry date: {$row['datedue']}", '441268206297');
Re: send SMS php coding
Posted: Thu Jul 09, 2015 9:18 am
by Celauran
Have you checked the value of $row['mobnumber']?
Re: send SMS php coding
Posted: Thu Jul 09, 2015 9:19 am
by Celauran
Also, what's going on with all of the variables that are defined but never used?
Code: Select all
$originator = 'Tax Elephants';
$mobnumber = $row['mobnumber'];
$name = $row['name'];
$message = "Name:".$row['name'] . ' ' .$row['description'] . ' ' . 'Expiry Date:' . ' ' .$row['datedue'];
Re: send SMS php coding
Posted: Thu Jul 09, 2015 9:37 am
by Celauran
You may need to strip that space.
Re: send SMS php coding
Posted: Thu Jul 09, 2015 10:08 am
by Celauran
The error message specifically complains about the phone number, so the date doesn't factor into it. I've been looking through their documentation but it's not terribly helpful. I have noticed the country code is included in all their examples, though.
Re: send SMS php coding
Posted: Thu Jul 09, 2015 10:14 am
by Celauran
Certainly for testing.
Re: send SMS php coding
Posted: Thu Jul 09, 2015 10:44 am
by Celauran
Not being able to do it in one go isn't a problem. What's a problem is you're saving the modified value to a variable, then stripping the space from the $row value.
Re: send SMS php coding
Posted: Thu Jul 09, 2015 10:53 am
by Celauran
I think you'd need to contact them at this point. That looks like a valid number to me. They're complaining it's not an integer, so you could try casting to int.
I don't see any value in making changes to things in the database until you can get this to work reliably.
Re: send SMS php coding
Posted: Thu Jul 09, 2015 11:41 am
by Celauran
I'd have to see the entire code. If you're making all the modifications to $mobnumber and passing $row['mobnumber'] to your sendSMS function, for example, then of course it's going to fail.
Re: send SMS php coding
Posted: Thu Jul 09, 2015 12:25 pm
by Celauran
You can save it as 44... in the DB if you like, but that's not why it's working/not working. You're making the modifications to $mobnumber but passing $row['mobnumber'] into the sendSMS function.
Re: send SMS php coding
Posted: Thu Jul 09, 2015 12:41 pm
by Celauran
As I stated previously, variables are not interpreted inside single quotes.
Re: send SMS php coding
Posted: Thu Jul 09, 2015 1:15 pm
by Celauran
You don't need to use any quotes.
Code: Select all
$response = sendSMS('47799', '692px', $mobnumber, "{$row['description']} expiry date: {$row['datedue']}", '441268206297');
Even better for reusability
Code: Select all
$sms_user = '47799';
$sms_pass = '692px';
$sms_from = '441268206297';
$response = sendSMS($sms_user, $sms_pass, $mobnumber, "{$row['description']} expiry date: {$row['datedue']}", $sms_from);