PHP Session_start

Gestart doorWouterp51 reacties125 weergaven

52 berichten · pagina 1 van 4

Wouterp

Lid · Topicstarter

Berichten
1.631
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Heey,

Heb een probleempje op:
http://letsweb.nl/klant/menu.php.

De error:

Quote:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/goededag/domains/letsweb.nl/public_html/klant/menu.php:6) in /home/goededag/domains/letsweb.nl/public_html/klant/menu.php on line 7

Script:

<html>
<head>
<title>Menu</title>
</head>
<body>
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]connect.php[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM `site` WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" LIMIT 1"[/COLOR][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]$sql[/COLOR][COLOR= #007700]);[/COLOR]
 ?>
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruiker[/COLOR][COLOR= #007700]])) {[/COLOR] ?>  
<p><b>Wat wilt u gaan doen?</p></b>
<a href="controlpaneel.php">Account wijzigen</a></br>

[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"rank"[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR][URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]hoi[/COLOR][COLOR= #007700];};[/COLOR]?>
[COLOR= #0000BB]<?php[/COLOR] [COLOR= #007700]}[/COLOR]?>
</body>
<html>


Wat is de fout?

M.v.g. Wouter
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Op het einde ipv Misschien?
0
Berichten
3.074
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]
?>
<html>
<head>
<title>Menu</title>
</head>
<body>
[COLOR= #0000BB]<?php
$sql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM `site` WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" LIMIT 1"[/COLOR][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]$sql[/COLOR][COLOR= #007700]);[/COLOR]
 ?>
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruiker[/COLOR][COLOR= #007700]])) {[/COLOR] ?>  
<p><b>Wat wilt u gaan doen?</p></b>
<a href="controlpaneel.php">Account wijzigen</a></br>

[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"rank"[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR][URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]hoi[/COLOR][COLOR= #007700];};[/COLOR]?>
[COLOR= #0000BB]<?php[/COLOR] [COLOR= #007700]}[/COLOR]?>
</body>
</html>
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Joeyl schreef:
<html>
<head>
<title>Menu</title>
</head>
<body>
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]connect.php[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM `site` WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" LIMIT 1"[/COLOR][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]$sql[/COLOR][COLOR= #007700]);[/COLOR]
 ?>
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruiker[/COLOR][COLOR= #007700]])) {[/COLOR] ?>  
<p><b>Wat wilt u gaan doen?</p></b>
<a href="controlpaneel.php">Account wijzigen</a></br>

[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"rank"[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR][URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]hoi[/COLOR][COLOR= #007700];};[/COLOR]?>
[COLOR= #0000BB]<?php[/COLOR] [COLOR= #007700]}[/COLOR]?>
</body>
</html>
Zoals ik zei nopompom
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR] ?>
<html>
<head>
<title>Menu</title>
</head>
<body>
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]connect.php[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM `site` WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" LIMIT 1"[/COLOR][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]$sql[/COLOR][COLOR= #007700]);[/COLOR]
 ?>
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruiker[/COLOR][COLOR= #007700]])) {[/COLOR] ?>  
<p><b>Wat wilt u gaan doen?</p></b>
<a href="controlpaneel.php">Account wijzigen</a></br>

[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"rank"[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR][URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]hoi[/COLOR][COLOR= #007700];};[/COLOR]?>
[COLOR= #0000BB]<?php[/COLOR] [COLOR= #007700]}[/COLOR]?>
</body>
</html>


Session start moet altijd helemaal bovenaan de pagina
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
session_start moet altijd boven al het andere wat een header output. Du boven Header(); boven HTML. Boven plaintext.

Eventjes je session_start() dus op de eerste regel zetten.
0
Wouterp

Lid · Topicstarter

Berichten
1.631
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Alleen krijg nu geen T, De rank is wel 1. Wat doe ik fout? De file is nu:

[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR] ?>
<html>
<head>
<title>Menu</title>
</head>
<body>
[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]connect.php[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM `gebruikers` WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" LIMIT 1"[/COLOR][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]$sql[/COLOR][COLOR= #007700]);[/COLOR]
 ?>
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruiker[/COLOR][COLOR= #007700]])) {[/COLOR] ?>  
<p><b>Wat wilt u gaan doen?</p></b>
<a href="controlpaneel.php">Account wijzigen</a></br>

[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"rank"[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]""[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR][URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]t[/COLOR][COLOR= #007700];};[/COLOR]?>
[COLOR= #0000BB]<?php[/COLOR] [COLOR= #007700]}[/COLOR]?>
</body>
</html>
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bestaat $_SESSION[gebruiker] en $_GET[id] wel?
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR] ?>
<html>
    <head>
        <title>Menu</title>
    </head>

    <body>
    [COLOR= #0000BB]<?php[/COLOR]
        [URL="http://www.php.net/include"]include[/URL] [COLOR= #DD0000]connect.php[/COLOR][COLOR= #007700];[/COLOR]
    
        [COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM `gebruikers` WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" LIMIT 1"[/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]
        [COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700]);[/COLOR]

        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]gebruiker[/COLOR][COLOR= #007700]])) 
        {[/COLOR] 
              
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<p><b>Wat wilt u gaan doen?</n></p>[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<a href="controlpaneel.php">Account wijzigen</a><br />[/COLOR][COLOR= #007700];[/COLOR]
 
            [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"rank"[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700])
            {[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]t[/COLOR][COLOR= #007700];
            }
        }[/COLOR]
    ?>
    </body>
</html>
0
Berichten
3.314
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wtf is

"".$row["rank"]."" == 1

"STRING" gebruik je om een string in te verwerken maar anders moet je die samen de de .-en gewoon weglaten anders ga je 2 spaties + een nummer vergelijken met een nummer
0
Wouterp

Lid · Topicstarter

Berichten
1.631
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zou iemand me kunnen helpen via teamvieuwer?
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Goededag schreef:
Zou iemand me kunnen helpen via teamvieuwer?
Dan kan je best een PB sturen die de benodigde kennis heeft en op di moment dat je dit leest online is.
0
Wouterp

Lid · Topicstarter

Berichten
1.631
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Misschien kan je het ook zo:
regel 11

$sql = mysql_query("SELECT `rank` FROM `gebruikers` WHERE id = .$_SESSION[gebruiker]");


error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/goededag/domains/letsweb.nl/public_html/klant/menu.php on line 11
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
$sql = mysql_query("SELECT `rank` FROM `gebruikers` WHERE id = " . $_SESSION[gebruiker] . "");


ipv

$sql = mysql_query("SELECT `rank` FROM `gebruikers` WHERE id = .$_SESSION[gebruiker]");


Je moet echt letten op die kleine foutjes..
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