online leden
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
if(isset($_SESSION['uId']))
{
$f55 = mysql_query("SELECT * FROM `member_online` WHERE uId = " . $_SESSION['uId']) or die(mysql_error());
if(mysql_num_rows($f55) == 0)
{
mysql_query("INSERT INTO member_online (uLast, uPage, uId) VALUES (NOW(), '".$_SERVER['REQUEST_URI']."',". $_SESSION['uId'] .")") or die(mysql_error());
}else{
mysql_query("UPDATE member_online SET uLast = NOW(), uPage = '".$_SERVER['REQUEST_URI']."' WHERE uId = " . $_SESSION['uId']) or die(mysql_error());
mysql_query("UPDATE member_accounts SET uLast = NOW() WHERE uId = " . $_SESSION['uId']) or die(mysql_error());
}
}else{
$sss = mysql_query("SELECT * FROM gast_online WHERE gip = " . $_SERVER['REMOTE_ADR']) or die(mysql_error());
if(mysql_num_rows($sss) == 0)
{
mysql_query("INSERT INTO gast_online (uLast, uPage, gip) VALUES (NOW(), '".$_SERVER['REQUEST_URI']."',". $_SERVER['REMOTE_ADDR'] .")") or die(mysql_error());
}else{
mysql_query("UPDATE gast_online SET uLast = NOW(), uPage = '".$_SERVER['REQUEST_URI']."' WHERE gip = " . $_SERVER['REMOTE_ADDR']) or die(mysql_error());
}
}
?>
if(isset($_SESSION['uId']))
{
$f55 = mysql_query("SELECT * FROM `member_online` WHERE uId = " . $_SESSION['uId']) or die(mysql_error());
if(mysql_num_rows($f55) == 0)
{
mysql_query("INSERT INTO member_online (uLast, uPage, uId) VALUES (NOW(), '".$_SERVER['REQUEST_URI']."',". $_SESSION['uId'] .")") or die(mysql_error());
}else{
mysql_query("UPDATE member_online SET uLast = NOW(), uPage = '".$_SERVER['REQUEST_URI']."' WHERE uId = " . $_SESSION['uId']) or die(mysql_error());
mysql_query("UPDATE member_accounts SET uLast = NOW() WHERE uId = " . $_SESSION['uId']) or die(mysql_error());
}
}else{
$sss = mysql_query("SELECT * FROM gast_online WHERE gip = " . $_SERVER['REMOTE_ADR']) or die(mysql_error());
if(mysql_num_rows($sss) == 0)
{
mysql_query("INSERT INTO gast_online (uLast, uPage, gip) VALUES (NOW(), '".$_SERVER['REQUEST_URI']."',". $_SERVER['REMOTE_ADDR'] .")") or die(mysql_error());
}else{
mysql_query("UPDATE gast_online SET uLast = NOW(), uPage = '".$_SERVER['REQUEST_URI']."' WHERE gip = " . $_SERVER['REMOTE_ADDR']) or die(mysql_error());
}
}
?>
en als ik ingelogd ben werkt het
maar als ik niet ingelogd ben:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
wat is er fout?
Code (php)
1
$f55 = mysql_query("SELECT * FROM `member_online` WHERE uId = '".$_SESSION['uId']."'");
en op rij 18 ook:
je moet hoge enkele komma's zetten om de value die je uit de db wilt halen.
nu krijg ik at
(stukje van me IP)
Echo de query die de foutmelding oplevert eens, wellicht zie je dan al wat er fout gaat?
wat bedoel je?
krijg ik als ik in echo zet
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<?php
$sql = "SELECT * FROM tabel";
if(!$resultaat = mysql_query($sql)) {
echo mysql_error().' In query: '. $sql;
}
?>
$sql = "SELECT * FROM tabel";
if(!$resultaat = mysql_query($sql)) {
echo mysql_error().' In query: '. $sql;
}
?>
ik snap het niet :S
SQL beginnershandleiding
Lees bovenstaande handleiding eens door. Daarin wordt onder andere uitgelegd hoe je SQL queries uitvoert en fouten die daarbij optreden kunt herkennen en oplossen.
Lees bovenstaande handleiding eens door. Daarin wordt onder andere uitgelegd hoe je SQL queries uitvoert en fouten die daarbij optreden kunt herkennen en oplossen.
Opgelost
doen jullie hier aan slotjes?
nee, maar wel aan edit-knoppen.
Leg ook even uit hoe je het opgelost hebt. Wel zo handig voor iemand die hetzelfde probleem heeft.
Gewijzigd op 01/01/1970 01:00:00 door Niels
2. De stappen zijn: Eerst google, dan pas phphulp.
3. Wat wij hier deden is niets anders dan helpen, als je dat niet appricieert, rot dan maar op.
4. Wees niet triest dat je het niet verteld.
Normaal ben ik niet zo als ik een persoon niet ken, alleen sterf :']
We proberen je te helpen, doe je zo...
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
if(isset($_SESSION['uId']))
{
$f55 = mysql_query("SELECT * FROM `member_online` WHERE uId = '".$_SESSION['uId']."'");
if(mysql_num_rows($f55) == 0)
{
mysql_query("INSERT INTO member_online (uLast, uPage, uId) VALUES (NOW(), '".$_SERVER['REQUEST_URI']."',". $_SESSION['uId'] .")");
}else{
mysql_query("UPDATE member_online SET uLast = NOW(), uPage = '".$_SERVER['REQUEST_URI']."' WHERE uId = " . $_SESSION['uId']);
mysql_query("UPDATE member_accounts SET uLast = NOW() WHERE uId = '". $_SESSION['uId'] ."'");
}
}else{
$sss = mysql_query("SELECT * FROM gast_online WHERE gip = '". $_SERVER['REMOTE_ADDR'] ."'");
if(mysql_num_rows($sss) == 0)
{
mysql_query("INSERT INTO gast_online (uLast, uPage, gip) VALUES (NOW(), '".$_SERVER['REQUEST_URI']."','". $_SERVER['REMOTE_ADDR'] ."')");
}else{
mysql_query("UPDATE gast_online SET uLast = NOW(), uPage = '".$_SERVER['REQUEST_URI']."' WHERE gip = '". $_SERVER['REMOTE_ADDR'] ."'");
}
}
{
$f55 = mysql_query("SELECT * FROM `member_online` WHERE uId = '".$_SESSION['uId']."'");
if(mysql_num_rows($f55) == 0)
{
mysql_query("INSERT INTO member_online (uLast, uPage, uId) VALUES (NOW(), '".$_SERVER['REQUEST_URI']."',". $_SESSION['uId'] .")");
}else{
mysql_query("UPDATE member_online SET uLast = NOW(), uPage = '".$_SERVER['REQUEST_URI']."' WHERE uId = " . $_SESSION['uId']);
mysql_query("UPDATE member_accounts SET uLast = NOW() WHERE uId = '". $_SESSION['uId'] ."'");
}
}else{
$sss = mysql_query("SELECT * FROM gast_online WHERE gip = '". $_SERVER['REMOTE_ADDR'] ."'");
if(mysql_num_rows($sss) == 0)
{
mysql_query("INSERT INTO gast_online (uLast, uPage, gip) VALUES (NOW(), '".$_SERVER['REQUEST_URI']."','". $_SERVER['REMOTE_ADDR'] ."')");
}else{
mysql_query("UPDATE gast_online SET uLast = NOW(), uPage = '".$_SERVER['REQUEST_URI']."' WHERE gip = '". $_SERVER['REMOTE_ADDR'] ."'");
}
}
ervan gemaakt
en ik heb nu andere vraag
Code (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
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
<?php
include("inc/functies.php");
boven('Online leden');
$q = mysql_fetch_assoc(mysql_query("SELECT COUNT(1) AS onlinecount FROM member_online WHERE DATE_ADD(uLast, INTERVAL 150 SECOND) > NOW()")) or trigger_error(mysql_error());
$q = mysql_fetch_assoc(mysql_query("SELECT COUNT(1) AS onlinecount FROM gast_online WHERE DATE_ADD(uLast, INTERVAL 150 SECOND) > NOW()")) or trigger_error(mysql_error());
$rows = $q['onlinecount'];
echo 'Er ' . ($rows == 1 ? 'is ' . $rows . ' gebruiker / gast' : 'zijn ' . ($rows == 0 ? '0' : $rows) . ' gebruikers / gasten') . ' actief.<br />';
$online_query = mysql_query("SELECT * FROM `member_online` WHERE DATE_ADD(uLast, INTERVAL 150 SECOND) > NOW() ORDER BY `uLast` DESC") or trigger_error(mysql_error());
$online_query = mysql_query("SELECT * FROM `gast_online` WHERE DATE_ADD(uLast, INTERVAL 150 SECOND) > NOW() ORDER BY `uLast` DESC") or trigger_error(mysql_error());
if(mysql_num_rows($online_query) > 0)
{
echo '<table><tr><td><strong>Gebruikersnaam:</strong></td><td><strong>Laatst gezien:</strong></td><td><strong>Waar:</strong></td></tr>';
while($online = mysql_fetch_assoc($online_query))
{
$sq = mysql_query("SELECT * FROM member_accounts WHERE uId = ".$online['uId']."") or die(mysql_error());
while($online2 = mysql_fetch_assoc($sq))
{
if($online['uId'] != '0')
{
echo '<tr><td style="width: 150px;"><a href="index.php?p=profiel&id=' . htmlentities($online['uId']) . '"><span style="color:' . htmlentities($online2['uCol']) . ';font-weight: bold;width: 150px;">' . htmlentities($online2['uName']) . '</span></a></td><td>' . htmlentities($online['uLast']) . '</td><td><a href="' . htmlentities($online['uPage']) . '">' . htmlentities($online['uPage']) . '</a></td></tr>';
}else{
echo'<tr><td style="width: 150px;"><li>Gast</li></td><td>' . htmlentities($online['uLast']) . '</td><td><a href="' . htmlentities($online['uPage']) . '">' . htmlentities($online['uPage']) . '</a></td></tr>';
}
}
echo '</table>';
}}
onder();
?>
include("inc/functies.php");
boven('Online leden');
$q = mysql_fetch_assoc(mysql_query("SELECT COUNT(1) AS onlinecount FROM member_online WHERE DATE_ADD(uLast, INTERVAL 150 SECOND) > NOW()")) or trigger_error(mysql_error());
$q = mysql_fetch_assoc(mysql_query("SELECT COUNT(1) AS onlinecount FROM gast_online WHERE DATE_ADD(uLast, INTERVAL 150 SECOND) > NOW()")) or trigger_error(mysql_error());
$rows = $q['onlinecount'];
echo 'Er ' . ($rows == 1 ? 'is ' . $rows . ' gebruiker / gast' : 'zijn ' . ($rows == 0 ? '0' : $rows) . ' gebruikers / gasten') . ' actief.<br />';
$online_query = mysql_query("SELECT * FROM `member_online` WHERE DATE_ADD(uLast, INTERVAL 150 SECOND) > NOW() ORDER BY `uLast` DESC") or trigger_error(mysql_error());
$online_query = mysql_query("SELECT * FROM `gast_online` WHERE DATE_ADD(uLast, INTERVAL 150 SECOND) > NOW() ORDER BY `uLast` DESC") or trigger_error(mysql_error());
if(mysql_num_rows($online_query) > 0)
{
echo '<table><tr><td><strong>Gebruikersnaam:</strong></td><td><strong>Laatst gezien:</strong></td><td><strong>Waar:</strong></td></tr>';
while($online = mysql_fetch_assoc($online_query))
{
$sq = mysql_query("SELECT * FROM member_accounts WHERE uId = ".$online['uId']."") or die(mysql_error());
while($online2 = mysql_fetch_assoc($sq))
{
if($online['uId'] != '0')
{
echo '<tr><td style="width: 150px;"><a href="index.php?p=profiel&id=' . htmlentities($online['uId']) . '"><span style="color:' . htmlentities($online2['uCol']) . ';font-weight: bold;width: 150px;">' . htmlentities($online2['uName']) . '</span></a></td><td>' . htmlentities($online['uLast']) . '</td><td><a href="' . htmlentities($online['uPage']) . '">' . htmlentities($online['uPage']) . '</a></td></tr>';
}else{
echo'<tr><td style="width: 150px;"><li>Gast</li></td><td>' . htmlentities($online['uLast']) . '</td><td><a href="' . htmlentities($online['uPage']) . '">' . htmlentities($online['uPage']) . '</a></td></tr>';
}
}
echo '</table>';
}}
onder();
?>
heb ik maar ik krijg geen error
en hij zegt dat niemand online is
Maaar:
Niels schreef op 03.01.2010 17:27:
ik ga dat niet zeggen
ik heb het toch gezegd?