0
I have a script that brings the results of an sql search as follows:
$sql = (...);
$result = $db->query($sql);
while ($obj = mysqli_fetch_object($result)) {
$ids = $obj->id_prestador.",";
}
If I echo $ids after creating the $ids, it brings for example: "710, 720, 730,".
Then on another page I wish I could take this information so I can run a script that sends these ID’s to an application, how can I do?
I tried for cookie that would be the best for me, but then he only brought the first result ("710,").
$sql = (...);
$result = $db->query($sql);
while ($obj = mysqli_fetch_object($result)) {
$ids = $obj->id_prestador.",";
setcookie("cookieprestador",$ids)
}
I wish I could pick up on any page the $ids like "710, 720, 730,".
UPDATING: converted into array and used implode and worked, but when I do the setcookie gives Warning message: Cannot Modify header information - headers already sent by output Started at .....
Down as it turned out:
$files = array();
while ($obj = mysqli_fetch_array($result)) {
$files[] = $obj["id_prestador"];
}
$string = implode(', ', $files);
setcookie("cookieprestador",$string);
And why don’t you define the
cookie
after thewhile
?– Woss
I tried, but then the cookie comes blank
– Leandro Marzullo
@Leandromarzullo fixes error "Cannot Modify header information" by following this https://answall.com/questions/4251/erro-cannot-Modify-header-information if you still have a problem even after fixing the error if you still have another problem edit the question I’ll see if it’s possible to reopen.
– Guilherme Nascimento