Friday, March 9, 2018

php - Notice: Use of undefined constant method - assumed





Hello i'm using sms sender in php and i'm getting this error



Notice: Use of undefined constant method - assumed



that's my code



////////
/* Sender SMS */
////////


$request =""; //initialise the request variable
$param[method]= "sendMessage";
$param[send_to] = "91".$_SESSION['yourContact'];
$param[msg] = "vamsi biyah hello the sms is working ahhahahahah :D :D " . $_SESSION['tour_id'] . "";
$param[userid] = $sms_userid;
$param[password] = $sms_pass;
$param[v] = "1.1";
$param[msg_type] = "TEXT"; //Can be "FLASH”/"UNICODE_TEXT"/”BINARY”
$param[auth_scheme] = "PLAIN";

//Have to URL encode the values
foreach($param as $key=>$val) {
$request.= $key."=".urlencode($val);
//we have to urlencode the values
$request.= "&";
//append the ampersand (&) sign after each parameter/value pair
}
$request = substr($request, 0, strlen($request)-1);
//remove final (&) sign from the request
$url = "http://enterprise.smsgupshup.com/GatewayAPI/rest?".$request;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);
//echo $curl_scraped_page;

?>


and that's the error i'm getting:




Notice: Use of undefined constant method - assumed 'method'
Notice: Use of undefined constant send_to - assumed 'send_to'
Notice: Use of undefined constant msg - assumed 'msg'
Notice: Use of undefined constant userid - assumed 'userid'
Notice: Use of undefined constant password - assumed 'password'
Notice: Use of undefined constant v - assumed 'v'
Notice: Use of undefined constant msg_type - assumed 'msg_type'
Notice: Use of undefined constant auth_scheme - assumed 'auth_scheme'



could anyone please help me to understand what is this error and how can i solve it ?


Answer



You need to use quotes for your index otherwise it will consider as Constant variables:



Example:



$param['method']= "sendMessage";
$param['send_to'] = "91".$_SESSION['yourContact'];
$param['msg'] = "vamsi biyah hello the sms is working ahhahahahah :D :D " . $_SESSION['tour_id'] . "";

$param['userid'] = $sms_userid;
$param['password'] = $sms_pass;
$param['v'] = "1.1";
$param['msg_type'] = "TEXT"; //Can be "FLASH”/"UNICODE_TEXT"/”BINARY”
$param['auth_scheme'] = "PLAIN";

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...