Bad string ? WHY

$app->post(’/api/login’, function($request, $response) {

$email= $request->getParam(‘email’);
$pass= $request->getParam(‘pass’);
try
{
//get db object
$db = new db();
//connect
$db = $db->connect();
$sth = $db->prepare(“SELECT count(*) AS count FROM users WHERE email=:email AND password=:pass”);

$sth->bindParam(’:pass’, $pass);
$sth->bindParam(’:email’, $email);
$sth->execute();
$row = $sth->fetch();
if($row[‘count’]>0){
$output = array(
‘status’=>“1”,
‘login’=>“sucess”,
);
}
else{
$output = array(
‘status’=>“0”,
‘login’=>“fail”,
);
}
}
catch(Exception $ex){
$output = array(
‘status’=>“2”,
‘login’=>“error”,
);
}
// $object = (object) $output;
echo json_encode($output);
$db = null;
});

THE RESULT IS Bad String
Status 200 ok

Hi!

Replace this:

with this:

return $response->withJson($output);

Expected ‘:’ instead of ‘’ :confused:

This could be a malformed JSON. Please provide more details!

Capture

Capture

Check your index.php file for invalid PHP tags.

All other requets are working get post delete put just this

Then try to validate your JSON string here: https://jsonlint.com/

thanks for you :* :*