Jump to content
Bekijk in de app

Een betere weg om onze GTA community te volgen. Leer meer.

GTAGames.nl - De Nederlandse Grand Theft Auto Community!

Een volledig scherm app op het beginscherm inclusief notificaties, badges en meer.

Om deze app op je iPhone en iPad te installeren
  1. Druk op het icoon in Safari
  2. Scroll in het menu en druk op Zet op beginscherm.
  3. Druk op Voeg toe rechts bovenaan.
Om deze app op je Android toe te voegen
  1. Druk op het 3-punten menu (⋮) rechts bovenaan in de browser.
  2. Druk op Toevoegen aan beginscherm of Installeer app.
  3. Druk op Toevoegen om te bevestigen.
Geplaatst:
comment_518859

Hallo allemaal, ik heb een probleem. Ik heb de volgende script:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
//Calculate 60 days in the future
//seconds * minutes * hours * days + current time
$inTwoMonths = 60 * 60 * 24 * 60 + time(); 
setcookie(lastVisit, date("G:i - m/d/y"), $inTwoMonths);

if(isset($_COOKIE['lastVisit']))
$visit = $_COOKIE['lastVisit']; 
else
echo "You've got some stale cookies!";

echo "Your last visit was - ". $visit; 
?>
</body>
</html>

Het script werkt wel alleen krijg ik de volgende fout:

[b]Warning[/b]:  Cannot modify header information - headers already sent by (output started at /web-drive/gimyweb/homes/roy/counter.php:9) in [b]/web-drive/gimyweb/homes/roy/counter.php[/b] on line [b]10[/b]

Weet iemand waar dit door komt en hoe ik dit op kan lossen? Alvast bedankt. _O_

Featured Replies

Geplaatst:
comment_518863

Hey, Roy!

De functie setCookie() moet geplaatst worden vóórdat er enige output geparsed is. Dus voordat er tekst op het beeldscherm verschijnt, maar ook voordat je HTML tags gebruikt, of zelfs een spatie voor de <?php zet. Het zelfde geld ook voor de sessie gerelateerde functies en de header() functies. Kijk naar het volgende script:

   <?php
setCookie(x,x,x);
?>

Fout - Er staat een spatie (dat dus output is) voor <?php

Dus in jouw script zal dit wel werken:

<?php
$inTwoMonths = 60 * 60 * 24 * 60 + time();
  setcookie(lastVisit, date("G:i - m/d/y"), $inTwoMonths);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
//Calculate 60 days in the future
//seconds * minutes * hours * days + current time

if(isset($_COOKIE['lastVisit']))
$visit = $_COOKIE['lastVisit'];
else
echo "You've got some stale cookies!";

echo "Your last visit was - ". $visit;
?>
</body>
</html>

Succes!

Bewerkt: door ViceAgent

Een reactie plaatsen

Je kan nu een reactie plaatsen en pas achteraf registreren. Als je al lid bent, log eerst in om met je eigen account een reactie te plaatsen.

Gast
Op dit onderwerp reageren...

Recent actief 0

  • Er zijn hier geen geregistreerde gebruikers aanwezig.

Configureer push berichten

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.