Your syntax for urlencode() was fine.
You did however have problems with the rest of your syntax, as well as some just bad coding practices . . . 😉
*****Never pass users important data through any means where it could be picked up by anyone(ie; through URL). (See /////Comment #1).
You were also missing parts of your if statements, including a bunch of brace brackets.
Try this version of the code:
<?
$user = "vamuse";
$password = "pingpong";
$api_id = "239445";
$baseurl ="http://api.clickatell.com";
$text = urlencode("Congratulations Rachel Quigley, you have won an all expenses paid trip to Dave Dowlings house this weekend. Yippee ");
$to = $_POST['RecipientMob'];
// auth call
/////Comment #1
$url = $baseurl."/http/auth?user=".$user."&password=".$password."&api_id=".$api_id."";
// do auth call
$ret = file($url);
// split our response. return string is on first line of the data returned
$sess = split(":",$ret[0]);
if ($sess[0] == "OK") {
$sess_id = trim($sess[1]); // remove any whitespace
$url = $baseurl."/http/sendmsg?session_id=".$sess_id."&to=".$to."&text=".$text;
// do sendmsg call
$ret = file($url);
$send = split(":",$ret[0]);
if ($send[0] == "ID"){
echo "success<br>message ID: ". $send[1];
}else{
echo "send message failed";
}
} else {
echo "Authentication failure: ". $ret[0];
exit();
}
?>
Also, I worked only with the code that was posted. I am assuming that there is more code somewhere, including the $_POST['submit'] check and whatnot.