see my query
Select * from join_chat where
(user_1 = '24' and user_2 = '26') or
(user_1 = '26' and user_2 = '24')
please advice with a solution to this error from my api
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
</div>{"responce":true,"data":"20"}
2020-05-09 23:16:43.302 28439-30249/techline.carsapp W/System.err: org.json.JSONException: Value Select of type java.lang.String cannot be converted to JSONObject
2020-05-09 23:16:43.302 28439-30249/techline.carsapp W/System.err: at org.json.JSON.typeMismatch(JSON.java:112)
2020-05-09 23:16:43.302 28439-30249/techline.carsapp W/System.err: at org.json.JSONObject.(JSONObject.java:163)
2020-05-09 23:16:43.302 28439-30249/techline.carsapp W/System.err: at org.json.JSONObject.(JSONObject.java:176)
2020-05-09 23:16:43.303 28439-30249/techline.carsapp W/System.err: at util.CommonAsyTask.doInBackground(CommonAsyTask.java:104)
2020-05-09 23:16:43.303 28439-30249/techline.carsapp W/System.err: at util.CommonAsyTask.doInBackground(CommonAsyTask.java:23)
2020-05-09 23:16:43.303 28439-30249/techline.carsapp W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:333)
2020-05-09 23:16:43.303 28439-30249/techline.carsapp W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2020-05-09 23:16:43.303 28439-30249/techline.carsapp W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
2020-05-09 23:16:43.303 28439-30249/techline.carsapp W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2020-05-09 23:16:43.303 28439-30249/techline.carsapp W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2020-05-09 23:16:43.303 28439-30249/techline.carsapp W/System.err: at java.lang.Thread.run(Thread.java:764)
Message: count(): Parameter must be an array or an object that implements Countable
Filename: controllers/Api.php
Line Number: 801
<p>Backtrace:</p>
The method in the controller below
public function send_chat_data()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('join_id', 'join_id', 'trim|required');
$this->form_validation->set_rules('sender_id', 'sender_id', 'trim|required');
$this->form_validation->set_rules('message', 'message', 'trim|required');
if ($this->form_validation->run() == false) {
$data["responce"] = false;
$data["error"] = 'join id is required';
} else {
$post_date=date("Y-m-d m:i:s");
$send_chat = array(
"join_id"=>$this->input->post("join_id"),
"sender_id"=>$this->input->post("sender_id"),
"message"=>$this->input->post("message"),
"created_date"=>$post_date
);
$this->db->insert("chat", $send_chat);
$insertid = $this->db->insert_id();
$q = $this->db->query("Select * from join_chat where join_id= '".$this->input->post("join_id")."' limit 1");
$recever_id = 0;
$row = $q->row();
if ($row->user_1 == $this->input->post("sender_id")) {
$recever_id = $row->user_2;
} else {
$recever_id = $row->user_1;
}
$q2 = $this->db->query("Select * from chat where chat_id= '".$insertid."' limit 1");
$chat = $q2->row();
$data["responce"] = true;
$data["data"] = $chat;
$q_fcm = $this->db->query("Select * from users where user_id= '".$recever_id."' limit 1");
$row_fcm = $q_fcm->row();
$registatoin_ids =$row_fcm->user_gcm_code;
$message["title"] = $this->config->item('app_name');
$message["message"] = $this->input->post("message");
$message["image"] = "";
$message["created_at"] = date("Y-m-d h:i:s");
$message["obj"] = $chat;
$this->load->helper('gcm_helper');
$gcm = new GCM();
//$result = $gcm->send_topics("/topics/rabbitapp",$message ,"ios");
$result = $gcm->send_notification(array($registatoin_ids), $message, "android");
}
echo json_encode($data);
}
The error is from the line below
$row = $q->row();
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…