...

View Full Version : Injecting a variable



eon201
02-27-2012, 05: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.


<?php
// Include MailChimp + Text Marketer API
include_once('TMRestClient.php');

$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()}";
}
?>

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

eon201
02-27-2012, 05: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.

Weird.

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()}";
}

eon201
02-27-2012, 05:29 PM
Fixed now!

Thanks guys!!!!!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum