PHP echo $result '{"status" : "success"}'; -


this question has answer here:

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

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -