fork download
  1. <?php
  2. if(isset($_GET['add_favorite'])) {
  3. if(isset($_COKKIE['fav_ads_ids'])){
  4. $ads = implode(',', json_decode($_COOKIE['fav_ads_ids']));
  5. $favorite_id = SELECT id FROM suaTabela WHERE id NOT IN ({$ads}) ORDER BY RAND() LIMIT 1
  6. $arr = json_decode($_COOKIE['fav_ads_ids']);
  7. }else{
  8. $favorite_id = SELECT id FROM suaTabela ORDER BY RAND() LIMIT 1
  9. $arr = [];
  10. }
  11.  
  12. $arr[] = $favorite_id['id'];
  13. $arr = json_encode($arr);
  14. setcookie("fav_ads_ids", $arr, time() + (86400 * 30), "/");
  15. }
  16. print_r($_COOKIE['fav_ads_ids']);
Runtime error #stdin #stdout #stderr 0.02s 82560KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Parse error:  syntax error, unexpected 'id' (T_STRING) in /home/NAZ084/prog.php on line 4