400 Bad Request: The browser sent a request that this server could not understand (CURL PHP)

Viewed 714

im very confused, i done search my problem but not found for my solution i got error 400 Bad Request: The browser sent a request that this server could not understand if i use the variable in my curl header.. but if i use string this working.. this my script curl header

$headers = array(
   "Accept: application/json",
   "Connection: keep-alive",
   'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
   'Content-Type: application/json',
   "cookie: ".$g,
);

so if i call the variable $g in my database like this $g = $reslt->cookie;

i got error

400 Bad Request: The browser sent a request that this server could not understand

but if i use the variable $g like this $g= 'PHPSESSID=t07gb66oduc55n982al83a7';

this working ...

i want to ask how to get curl working if variable $g is called from my database. even though the contents in the database are correct , if I call

echo $reslt->cookie;

then the contents show like this

PHPSESSID=t07gb66oduc55n982al83a7

1 Answers

SOLVED .. i must use a trim in $reslt->cookie;

Related