下面我要描述我的代码。代码的所有连接和流程都是完美的但是当$ sql查询在$ result变量中得到结果为null时,请给我一个正确的解决方案。
这是服务器端远程通知的代码。
<?php
error_reporting(0);
include_once('PushNotification.php');
// Message payload
$msg_payload = array (
'mtitle' => 'Signature Request',
'mdesc' => 'Please Sign The Document.',
);
if( $_SERVER['REQUEST_METHOD']=='POST' && $_POST['signers']){ //pass parameter through url
$signer_array = $_POST['signers'];
$conn = mysql_connect('pixster.pixsterstudio.com','xxxx','xxxx') or die('Cannot connect to the DB');
mysql_select_db('easy_sign',$conn);
for ($i = 0; $i < count($signer_array); $i++) {
$signer = ($signer_array[$i]);
//$signer = 'pixstertest@gmail.com';
$sql = "SELECT device_token FROM register WHERE email = '$signer'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) != 0) {
while($row = mysqli_fetch_assoc($result)) {
$deviceToken = $row["device_token"];
PushNotifications::iOS($msg_payload, $deviceToken);
$json = array('status'=>1,'Message'=>"Send Notification");
}
}
else{
$json = array('status'=>0,'Message'=>$sql);
}
}
}
echo json_encode($json);
?>