View Full Version : Injecting a variable

02-27-2012, 06:05 PM
Hi guys,

Thanks for your help in advance.

I have a form which submits data to a php script.

It basically sends a user a text when they fill out a form.

The problem is the text comes in like this:
'Hi $name, Thanks for applying to the guestlist.'

All I want to do is inject the variable $name so that is appears like so:

'Hi Eon201, Thanks for applying to the guestlist.'

I can't work out what im doing wrong!

Please help. Thanks in advance.

// Include MailChimp + Text Marketer API

$tmClient = new TMRestClient('********', '*****', 'production');
try {
$result = $tmClient->sendSMS('Hi $name, Thanks for applying to the guestlist.', '*******', 'Capital A');
echo "Used {$result['credits_used']} Credits, message ID {$result['message_id']}";
} catch (Exception $ex) {
echo "Error: {$ex->getCode()}, {$ex->getMessage()}";

02-27-2012, 06:11 PM
Solution is simple, just change single quotes for double quotes and it should work

02-27-2012, 06:25 PM
Thanks that worked a treat....

But I do have an issue now with the variable $mobile (the number they supplied). I can get it to 'echo' so I know the data is there but for some reason if I try to inject it into the api below as shown it doesnt seem to work.

I the variable of $mobile is in there I receive no txt, but if I put any other number in the php say '07702219***' it works.


Any ideas? Thanks in advance.

$tmClient = new TMRestClient(*********, '*****', 'production');
try {
$result = $tmClient->sendSMS("Hi $name We will contact you shortly to confirm your guestlist application. Please check your email. www.*******.com *********", "$mobile", 'Capital A');
} catch (Exception $ex) {
echo "Error: {$ex->getCode()}, {$ex->getMessage()}";

02-27-2012, 06:29 PM
Fixed now!

Thanks guys!!!!!!