PHP echo $result '{"status" : "success"}'; -
this question has answer here:
- php parse/syntax errors; , how solve them? 11 answers
could please tell me wrong function. found in video: https://www.youtube.com/watch?v=871_pmieyxi (1:24)
i'm getting error: parse error: syntax error, unexpected ''{"status" : "success"}'' (t_constant_encapsed_string), expecting ',' or ';' in c:\xampp\htdocs\myproject\application\controllers\usercontroller.php on line 26
line 26 line: echo $result '{"status" : "success"}';
public function add() { $postdata = file_get_contents("php://input"); $request = json_decode($postdata); $name = $request->name; $city = $request->city; $id = $this->user_model->adduser($name,$city); if($id) { echo $result '{"status" : "success"}'; } else { echo $result '{"status" : "failure"}'; } }
if don't have else in $result
just
if($id) { echo '{"status" : "success"}'; } else { echo '{"status" : "failure"}'; }
but if have more data in $result, missed .
parse error because code not being concatenated correctly.
Comments
Post a Comment