[SPOED] PHP probleempje

Gestart doorJosnl9 reacties25 weergaven

10 berichten · pagina 1 van 1

Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo allemaal,

EDIT 2:

Weet iemand waarom ik niks krijg te zien als ik de aantallen ophaal uit de database stats (kolom = aantal)?

[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"config.php"[/COLOR][COLOR= #007700]);[/COLOR] ?>
<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>

[COLOR= #0000BB]<?php

$ip[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]];[/COLOR]

[COLOR= #0000BB]$qSelect[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT `aantal` FROM `stats` WHERE ip="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$ip[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" LIMIT 1"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$qFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qSelect[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rij[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$qFetch[/COLOR][COLOR= #007700]){[/COLOR]
    
    [COLOR= #0000BB]$uniek[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$rij[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantal[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$uniek[/COLOR][COLOR= #007700];

}[/COLOR]

?>
</body>
</html>


Thanks in advance!biggrin
0
Berichten
1.674
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Vraag 2: Variable uniek zie ik niet?
Nergens aangegeven maar wel in je echo..
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Regel 20???
0
Berichten
1.674
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
oeeepsbloos
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Iemand een oplossing?bloos
0
Berichten
1.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Haal die LIMIT 1 is weg en dan kijken of hij wel werktwink
0
Berichten
1.674
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik kijk de code na voor je.
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Okee, dankjewel!

Ik heb het nu zo:

[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"config.php"[/COLOR][COLOR= #007700]);[/COLOR] ?>
<!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>

[COLOR= #0000BB]<?php

$qSelect[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT `aantal` FROM `stats`"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$tel[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qSelect[/COLOR][COLOR= #007700]);[/COLOR]


[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$tel[/COLOR][COLOR= #007700];[/COLOR]

?>
</body>
</html>


Alleen krijg ik dan als output 1, terwijl er meerdere keren die pagina bezocht is...

OPGELOST!

Hele script:

[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"config.php"[/COLOR][COLOR= #007700]);[/COLOR] ?>
<!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=utf-8" />
<title>Statistieken</title>
</head>

<body>

[COLOR= #0000BB]<?php

$ip[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]];[/COLOR]

[COLOR= #0000BB]$qSelect[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT `ip` FROM `stats` WHERE ip="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$ip[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$qCount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qSelect[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qCount[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]

[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO `stats`(ip) VALUES("[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$ip[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]")"[/COLOR][COLOR= #007700]);

}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]

[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE `stats` SET aantal=aantal+1 WHERE ip="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$ip[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);

}[/COLOR]

[COLOR= #0000BB]$qSelectA[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT aantal FROM stats"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$qResultA[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qSelectA[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]

[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qResultA[/COLOR][COLOR= #007700])){[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je site heeft "[/COLOR][COLOR= #007700].[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantal[/COLOR][COLOR= #007700]] .[/COLOR][COLOR= #DD0000]" pageviews!"[/COLOR][COLOR= #007700];

}[/COLOR]

?>

</body>
</html>
0
Berichten
5.957
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je telt het aantal gevonden rijen, je moet i.p.v. mysql_num_rows mysql_fetch assoc gebruiken. Kijk op w3schools voor een goede tutorial.
0
Josnl

Lid · Topicstarter

Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zie mn edit, had t al gevonden wink
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren