Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Injecting a variable

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

  • #2
    New to the CF scene
    Join Date
    Feb 2012
    Location
    Newbury Uk
    Posts
    7
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Solution is simple, just change single quotes for double quotes and it should work

  • #3
    New Coder
    Join Date
    Oct 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    PHP Code:
          $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()}";
          } 

  • #4
    New Coder
    Join Date
    Oct 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Fixed now!

    Thanks guys!!!!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •