我想捕获$ status并将其插入数据库'smsdb'。但是,我无法这样做,希望有人能指导我。 这个起始代码是wall函数的一部分,也就是在调用函数之后获取状态的地方。在grabdetails函数中,我将其他详细信息放入db中,$ status无法访问。请有人带我去...... //代码
$name = $resultarr['name'];
$amount = $resultarr['amount'];
$transaction_id = $resultarr['trans_id'];
$date = $resultarr['time_paid'];
//message template
$message = "Dear $name we have received $amount from you. MPESA transaction Id $transaction_id on $date.";
$mobilenumber = $resultarr['msisdn']; // get mobile number from array
$message_sent = $message;
$serviceArguments = array(
"mobilenumber" => $mobilenumber,
"message" => $message_sent
);
$client = new SoapClient("http://59.38.606.10:8080/smsengine/smsws?WSDL");
$result = $client->process($serviceArguments);
grabdetails($message_sent, $mobilenumber);
return $result;
}
//I call the function wall() to send sms
wall();
$perm = wall();
$status = $perm->return; //outputing the status
// Here I want to capture the $status variable and put it in a db below
echo "$status";
function grabdetails($messagee, $mobno)
{
$message_sent = $messagee;
$mobilenumber = $mobno;
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "smsdb";
// Create connection
// Check connection
$sql = "INSERT INTO smsdb (sms_text, receiver_number, time_sent, status)
VALUES
('$message_sent', '$mobilenumber', NOW(), '$status' )";
$conn->query($sql);
任何人?
答案 0 :(得分:1)
intent://instagram.com/_u/ververa/#Intent;package=com.instagram.android;scheme=https;end
变量为$status
。
添加以下行:
out of scope
为了你的功能。
http://php.net/manual/en/language.variables.scope.php
编辑:
当您在global $status;
函数中调用grabdetails
时,wall()
变量尚未设置。也许可以在$status
函数中将状态作为grabdetails
函数中的参数传递。
e.g。 wall()
同时将函数声明更改为grabdetails($message_sent, $mobilenumber, $result);