我想要捕獲$狀態並將其插入到數據庫的'smsdb'中。但是,我無法這樣做,並希望有人會指導我。 此起始代碼是牆功能的一部分,並且在調用該函數之後獲取狀態。在grabdetails函數中,我將其他詳細信息導入到db中,$ status是無法訪問的。會有人領我請... //代碼PHP Mysql插入數據到數據庫中的函數
$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);
任何一個?
請給予適當的打開和關閉括號在代碼 –
到底在哪?請致電 –
此功能grabdetails在哪裏結束?它沒有右花括號,功能牆在哪裏? –