Help - PHP

Gestart doorSebastiaanh3 reacties44 weergaven

4 berichten · pagina 1 van 1

Sebastiaanh

Lid · Topicstarter

Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo iedereen,
Ik ben bezig met een chat, maar ik loop vast op een probleem.
Ik heb op dit moment deze code, maar hij laat de namen niet zien:

[COLOR= #0000BB]<?php
$verbinding[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"xxx"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"wwhier"[/COLOR][COLOR= #007700]);[/COLOR]
                     [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"xxx"[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$select[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM chat"[/COLOR][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_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$select[/COLOR][COLOR= #007700])) {[/COLOR]
        [COLOR= #0000BB]$row[/COLOR][COLOR= #007700]([/COLOR]htmlentities[COLOR= #007700]([[/COLOR][COLOR= #DD0000]"naam"[/COLOR][COLOR= #007700]]));
    }[/COLOR]
?>

<form action="#" method="post" />
<textarea name="chat" cols="70px;" rows="10px;" />[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700]([/COLOR]htmlentities[COLOR= #007700]([[/COLOR]naam[COLOR= #007700]]));[/COLOR] ?></textarea> 
</form>


Mvg,
Sebastiaan H
0
Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$verbinding[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"xxx"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"wwhier"[/COLOR][COLOR= #007700]);[/COLOR]
                     [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"xxx"[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$select[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM chat"[/COLOR][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_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$select[/COLOR][COLOR= #007700])) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700]([/COLOR]htmlentities[COLOR= #007700]([[/COLOR][COLOR= #DD0000]"naam"[/COLOR][COLOR= #007700]]));
    }[/COLOR]
?>

<form action="#" method="post" />
<textarea name="chat" cols="70px;" rows="10px;" />[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700]([/COLOR]htmlentities[COLOR= #007700]([[/COLOR]naam[COLOR= #007700]]));[/COLOR] ?></textarea>
</form>
0
Sebastiaanh

Lid · Topicstarter

Berichten
9.953
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Heb hem werkend.
Maar nu maakt hij elke keer als er een nieuw bericht is een nieuwe textarea aan.
Hoe verhelp ik dit?
Code:

if(isset($_POST[submit])) {
mysql_query("INSERT INTO chat (bericht) VALUES (".mysql_real_escape_string($_POST[bericht]).")");
}else{

$select = mysql_query("SELECT * FROM chat");

    while ($row = mysql_fetch_assoc($select)) {
             echo $row[naam];
?>

<form action="#" method="post" />
<textarea name="chat" cols="70px;" rows="10px;" />[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR]naam[COLOR= #007700]] .[/COLOR][COLOR= #DD0000]: [/COLOR][COLOR= #007700].[/COLOR]  [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR]bericht[COLOR= #007700]];[/COLOR] ?></textarea> <br />
<textarea name="bericht" cols="70px;" rows="5px;" /> </textarea> <input type="submit" name="submit" value="Verzenden" />
</form>

[COLOR= #0000BB]<?php[/COLOR]
    [COLOR= #007700]}
}[/COLOR]
?>
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Kijk eens even heel goed naar je while-lus en waar je hem afsluit.. Zo moeilijk is dat toch niet?
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