[php] tellerscript, zie variabelen niet

Pagina: 1
Acties:

  • Mithrandir
  • Registratie: Januari 2001
  • Laatst online: 16-09 21:52
Wou in de titel zeggen: tellerscript, de variabelen kunnnen niet weergegeven worden, maar dat was te lang :+

Ik heb een mooi script gemaakt voor een teller, maar nu loop ik vast nu ik 't verander. (oude script: zie http://www.phpfreakz.com/library.php?sid=948 ).

het complete nieuwe script:
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?
//Functie SchrijfBestand ----------------------------------
function schrijf_bestand($BestandsName,$ValueName)
{
if (is_file($BestandsName))
    {
    $TijdName = $BestandsName;
    include("$BestandsName");
    $TijdValue++;
    $file2 = fopen("$BestandsName","w");
    fputs($file2, "<");
    fputs($file2, "?php $");
    fputs($file2, "$TijdName = $TijdValue ?");
    fputs($file2, ">");
    fclose($file2);
    }
else
    {
    $TijdName = $BestandsName;
    $file = fopen("$BestandsName","w");
    fputs($file, "<");
    fputs($file, "?php $");
    fputs($file, "$TijdName = 1 ?");
    fputs($file, ">");
    $TijdValue = 1;
    fclose($file);
    }
}
//einde Functie schrijf_bestand ---------------------------

//Functie Teller...----------------------------------------
function teller($tijd, $PerPagina)
{
$FileName = ("counter//".$tijd.".dat");
$pagina = str_replace(".", "", $PHP_SELF);
$TijdName = ($tijd.$pagina);

//Checken of PerPagina ja is of nee. Indien ja, FileName2 maken. Anders niet.
if ($PerPagina)
    {
    $FileName2 = ("counter//".$tijd."_".$pagina.".dat");
    }

if (isSet($FileName2))
    {
    schrijf_bestand($FileName2,$tijd);
    schrijf_bestand($FileName,$tijd);
    }
else
    {
    schrijf_bestand($FileName,$tijd);
    }

}
//Einde Functie Teller ------------------------------------
?>




</HEAD>
<BODY>

<?php
//DAGTELLING VOOR ALLE PAGINAS
$DagNu = (date(Y) . date(m) . date(d));
$MaandNu = (date(Y) . date(m));
$JaarNu = date(Y);

$DagVarPagina = teller($DagNu, true);
$DagVar = teller($DagNu, false);
$MaandVarPagina = teller($MaandNu, true);
$MaandVar = teller($MaandNu, false);
$JaarVarPagina = teller($JaarNu, true);
$Jaarvar = teller($Jaarnu, false);

echo("De counter van deze pagina: <BR>");
echo("counter per dag: ".$DagVarPagina."<BR>");
echo("counter per maand: ".$MaandVarPagina."<BR>");
echo("counter per Jaar: ".$JaarVarPagina."<BR>");
echo("<BR>");
echo("De counter van alle paginas: <BR>");
echo("counter per dag: ".$DagVar."<BR>");
echo("counter per maand: ".$MaandVar."<BR>");
echo("counter per Jaar: ".$JaarVar."<BR>");
?>

Hij geeft geen fouten weer, maar hij laat alle variabelen niet zien :'(.

urltje waar 't bestand nu staat (gaat offline als ik offline ben)

Dit is de file waar hij alle bestanden opslaat

Wat doe ik fout?

Verbouwing


  • LuCarD
  • Registratie: Januari 2000
  • Niet online

LuCarD

Certified BUFH

http://nl.php.net/manual/en/functions.returning-values.php

Je bent in je functie's vergeten een return value op te geven.

URL verteld je hoe je dat zou kunnen doen.

Programmer - an organism that turns coffee into software.


  • Mithrandir
  • Registratie: Januari 2001
  • Laatst online: 16-09 21:52
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?
<HTML>
<HEAD>
<TITLE>
Teller
</TITLE>

<?php
//Functie SchrijfBestand ----------------------------------
function schrijf_bestand($BestandsName,$ValueName)
{
if (is_file($BestandsName))
    {
    $TijdName = $BestandsName;
    include("$BestandsName");
    $TijdValue++;
    $file2 = fopen("$BestandsName","w");
    fputs($file2, "<");
    fputs($file2, "?php $");
    fputs($file2, "$TijdName = $TijdValue ?");
    fputs($file2, ">");
    fclose($file2);
    return $TijdValue;
    }
else
    {
    $TijdName = $BestandsName;
    $file = fopen("$BestandsName","w");
    fputs($file, "<");
    fputs($file, "?php $");
    fputs($file, "$TijdName = 1 ?");
    fputs($file, ">");
    $TijdValue = 1;
    fclose($file);
    return $TijdValue;
    }
}
//einde Functie schrijf_bestand ---------------------------

//Functie Teller...----------------------------------------
function teller($tijd, $PerPagina)
{
$FileName = ("counter//".$tijd.".dat");
$pagina = str_replace(".", "", $PHP_SELF);
$TijdName = ($tijd.$pagina);

//Checken of PerPagina ja is of nee. Indien ja, FileName2 maken. Anders niet.
if ($PerPagina)
    {
    $FileName2 = ("counter//".$tijd."_".$pagina.".dat");
    }

if (isSet($FileName2))
    {
    $antwoord = schrijf_bestand($FileName2,$tijd);
    return $antwoord;
    }
else
    {
    $antwoord = schrijf_bestand($FileName,$tijd);
    return $antwoord;
    }

}
//Einde Functie Teller ------------------------------------
?>




</HEAD>
<BODY>

<?php
//DAGTELLING VOOR ALLE PAGINAS
$DagNu = (date(Y) . date(m) . date(d));
$MaandNu = (date(Y) . date(m));
$JaarNu = date(Y);

$DagVarPagina = teller($DagNu, true);
$DagVar = teller($DagNu, false);
$MaandVarPagina = teller($MaandNu, true);
$MaandVar = teller($MaandNu, false);
$JaarVarPagina = teller($JaarNu, true);
$JaarVar = teller($JaarNu, false);

echo("De counter van deze pagina: <BR>");
echo("counter per dag: ".$DagVarPagina."<BR>");
echo("counter per maand: ".$MaandVarPagina."<BR>");
echo("counter per Jaar: ".$JaarVarPagina."<BR>");
echo("<BR>");
echo("De counter van alle paginas: <BR>");
echo("counter per dag: ".$DagVar."<BR>");
echo("counter per maand: ".$MaandVar."<BR>");
echo("counter per Jaar: ".$JaarVar."<BR>");
?>

</BODY>
</HTML>
?>

Dat is 't nu, maar doet 't nog niet. Geen foutmelding, maar de variabelen blijven op 1 staan.

Verbouwing


  • D2k
  • Registratie: Januari 2001
  • Laatst online: 31-08 10:19

D2k

bekijk de inhoud van die files eens kritische
dat klopt niet volgens mij?

Doet iets met Cloud (MS/IBM)


  • D2k
  • Registratie: Januari 2001
  • Laatst online: 31-08 10:19

D2k

PHP:
1
2
3
<?
$TijdValue++;
?>

als je nou eerst eens
PHP:
1
2
3
<?
echo "tijd : $TijdValue";
?>

doet
zie je dat dat geen waarde heeft
fix eerst dat maar eens en kijk dan maar eens naar de rest van je script

Doet iets met Cloud (MS/IBM)


  • Mithrandir
  • Registratie: Januari 2001
  • Laatst online: 16-09 21:52
laat maar. Ik ga 'm helemaal overnieuw scripten.

Verbouwing


  • flat
  • Registratie: Mei 2000
  • Niet online
Op zaterdag 03 november 2001 17:13 schreef DinoRaptor het volgende:
laat maar. Ik ga 'm helemaal overnieuw scripten.
ja goed plan, ik vind dat 'ie sowieso erg onlogisch in elkaar zit

"Happiness is a way of travel, not a destination."
--Roy Goodman

Pagina: 1