send SMS php coding

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: send SMS php coding

Post 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');
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: send SMS php coding

Post by Celauran »

Have you checked the value of $row['mobnumber']?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: send SMS php coding

Post 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'];
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: send SMS php coding

Post by Celauran »

You may need to strip that space.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: send SMS php coding

Post 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.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: send SMS php coding

Post by Celauran »

Certainly for testing.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: send SMS php coding

Post 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.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: send SMS php coding

Post 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.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: send SMS php coding

Post 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.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: send SMS php coding

Post 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.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: send SMS php coding

Post by Celauran »

As I stated previously, variables are not interpreted inside single quotes.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: send SMS php coding

Post 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);
Post Reply