没有';无法获取php文件中所有值的数据库
我正在创建一个没有';无法获取php文件中所有值的数据库,php,android,Php,Android,我正在创建一个PHP文件,用于使用POST方法在android设备上发送推送通知。当我在HTML页面上插入值时,数据会进入PHP页面,但我的PHP数组没有获取所有行值。我怎样才能解决这个问题 <?php require "init.php"; $message = $_POST['message']; $title = $_POST['title']; $path_to_fcm='https://android.googleapis.com/gcm/send
PHP
文件,用于使用POST
方法在android设备上发送推送通知。当我在HTML
页面上插入值时,数据会进入PHP
页面,但我的PHP
数组没有获取所有行值。我怎样才能解决这个问题
<?php
require "init.php";
$message = $_POST['message'];
$title = $_POST['title'];
$path_to_fcm='https://android.googleapis.com/gcm/send';
$server_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
$sql = "select fcm_token from fcm_info";
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_row($result);
$key = $row[0];
$headers = array('Authorization:key=' .$server_key,
'Content_Type:application/json');
$fields = array('to'=>$key,'notification'=>array('title'=>$title,'body'=>$message));
$payload = json_encode($fields);
$curl_session = curl_init();
curl_setopt($curl_session,CURLOPT_URL,$path_to_fcm);
curl_setopt($curl_session,CURLOPT_POST,true);
curl_setopt($curl_session,CURLOPT_HTTPHEADER,$headers);
curl_setopt($curl_session,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl_session,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($curl_session,CURLOPT_IPRESOLVE,CURL_IPRESOLVE_V4);
curl_setopt($curl_session,CURLOPT_POSTFIELDS,$payload);
$result = curl_exec($curl_session);
curl_close($curl_session);
mysqli_close($con);
?>
where iswhile
要从db
检索所有数据,我是php中的新手,只需告诉我use loopmysqli\u fetch\u row($result)
从何处获取结果集的一行,因此只需一个条目。您必须循环并执行该命令,直到您读取了所有条目。@Atish请尝试更新代码并确认您在表中的记录不止一条,或者确保您的fcm_标记的格式正确,如长度
$key_array=array();
while ($row = mysqli_fetch_assoc($result)) {
array_push($key_array,$row['fcm_token']);
}