unten ist der Quellcode für eine Shoutbox. Leider läuft das nicht. Es wird nichts in die Datenbank eingetragen und somit wird als Shoutbox auch nichts angezeigt. Fehlermeldung gibt es keine. Vielleicht erkennt jemand eine Lösung?
danke und gruß
Code: Alles auswählen
<?
//the host, name, and password for your mysql
mysql_connect("localhost","***","***");
//select the database
mysql_select_db("***");
if($submit)
{
//use the PHP date function for the time
$time=date("h:ia d/j/y");
// inserting it into the shoutbox table which we made in the mysql statements before
$result=MYSQL_QUERY("INSERT INTO shoutbox (id,name,message,time)".
"VALUES ('NULL','$name', '$message','$time')");
}
?>
<?
//returning the last 5 messages
$result = mysql_query("select * from shoutbox order by id desc limit 5");
//the while loop
while($r=mysql_fetch_array($result))
{
//getting each variable from the table
$time=$r["time"];
$id=$r["id"];
$message=$r["message"];
$name=$r["name"];
?>
<? echo $time ?><br>
<? echo $name ?><br>
<? echo $message ?><br>
<? } ?>
<form action="<? echo $php_self ?>" method="post">
<INPUT TYPE='TEXT' value='name' NAME='name' SIZE=30 maxlength='100'><br>
<INPUT TYPE='TEXT' value='message' NAME='message' SIZE=30 maxlength='100'>
<input type="submit" name="submit" value="submit">
</form>