[code]<?
//the host, name, and password for your mysql
mysql_connect(“localhost”,“ashley4fans”,“DASSCHREIBEICHNICHTINSFORUM”);
//select the database
mysql_select_db(“ashley4fans”);
if($submit)
{
//use the PHP date function for the time
$time=date(“h:i d.m.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)) //dort steht anscheinend der fehler?!
{
//getting each variable from the table
$time=$r["time"];
$id=$r["id"];
$message=$r["message"];
$name=$r["name"];
?>
<? echo $time ?>
<? echo $name ?>
<? echo $message ?>
<? } ?>[/code]
//returning the last 5 messages
$result1 = mysql_query("SELECT * FROM `shoutbox ` ODRDER BY `id` DESC LIMIT 5");
//the while loop
while($r=mysql_fetch_array($result1)) //dort steht anscheinend der fehler?!
{
//returning the last 5 messages
$result1 = mysql_query("SELECT * FROM `shoutbox ` ODRDER BY `id` DESC LIMIT 5");
//the while loop
while($r=mysql_fetch_array($result1)) //dort steht anscheinend der fehler?!
{
und sag ob die meldung immernoch kommt.[/quote]
Aber kopiere nicht den Code von iNaD 1:1. Hier ist ein fehler drin Es muß natürlich ORDER heissen - nicht ODRDER
[code]<?
//the host, name, and password for your mysql
mysql_connect(“localhost”,“ashley4fans”,“DASSCHREIBEICHNICHTINSFORUM”);
//select the database
mysql_select_db(“ashley4fans”);
if($submit)
{
//use the PHP date function for the time
$time=date(“h:i d.m.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
$result1 = mysql_query("SELECT * FROM `shoutbox` ORDER BY `id` DESC LIMIT 5");
//the while loop
while($r=mysql_fetch_array($result1))
{
//getting each variable from the table
$time=$r["time"];
$id=$r["id"];
$message=$r["message"];
$name=$r["name"];
echo $time;
echo $name.' ';
echo $message.' ';
} ?>[/code]
Ersetze mal in iNaD’s Code in Zeile 20$result1 = mysql_query("SELECT * FROM `shoutbox` ORDER BY `id` DESC LIMIT 5");mit$result1 = mysql_query("SELECT * FROM `shoutbox` ORDER BY `id` DESC LIMIT 5") or die(mysql_error());
Das Passwort natürlich auch noch anpassen…
Ja klar, es kann ja nichts in deine Datenbank geschrieben werden. Hier giltglobals=off, also musst du
if($submit)
{
//use the PHP date function for the time
$time=date("h:i d.m.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')");
}
?>
entsprechend anpassen. Also $submit usw. durch $_GET[‘submit’] bzw. $_POST[‘submit’] ersetzen.
Oh Gott, da hab ich das Offensichtliche übersehen.
@Sebi: $result=MYSQL_QUERY("INSERT INTO shoutbox (id,name,message,time)".
"VALUES ('NULL','$name', '$message','$time')");
Das wird dank register_globals = Off auch nicht funktionieren.
dann hier der gesamte code:
schon mal vielen dank!
[code]<?
//the host, name, and password for your mysql
mysql_connect(“localhost”,“ashley4fans”,“SAG ICH NICHT”);
//select the database
mysql_select_db(“ashley4fans”);
if($submit)
{
//use the PHP date function for the time
$time=date(“h:i d.m.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
$result1 = mysql_query("SELECT * FROM `shoutbox` ORDER BY `id` DESC LIMIT 5") or die(mysql_error());
//the while loop
while($r=mysql_fetch_array($result1))
{
//getting each variable from the table
$time=$r["time"];
$id=$r["id"];
$message=$r["message"];
$name=$r["name"];
echo $time;
echo $name.' ';
echo $message.' ';
} ?>
[/code]
if($_POST('submit')
{
//use the PHP date function for the time
$time=date("h:i d.m.Y");
// inserting it into the shoutbox table which we made in the mysql statements before
$result=MYSQL_QUERY("INSERT INTO shoutbox (name,message,time)".
'VALUES ("' . $_POST('name') . '", "' . $_POST('message') . '", "' . $time . '")');
}
?>
Leider tritt nun folgender Fehler auf:Parse error: syntax error, unexpected ‘{’ in /users/ashley4fans/www/shout.php on line 9
(siehe auch Code)[code]
if($_POST(‘submit’)
{ <<<<<das wird jetzt als UNEXPECTED angesehen
//use the PHP date function for the time
$time=date(“h:i d.m.Y”);
// inserting it into the shoutbox table which we made in the mysql statements before
$result=MYSQL_QUERY(“INSERT INTO shoutbox (name,message,time)”.
‘VALUES ("’ . $_POST(‘name’) . ‘", "’ . $_POST(‘message’) . ‘", "’ . $time . ‘")’);
}
?>
[/code]
[code]if($_POST(‘submit’))
{ <<<<<das wird jetzt als UNEXPECTED angesehen
//use the PHP date function for the time
$time=date(“h:i d.m.Y”);
// inserting it into the shoutbox table which we made in the mysql statements before
$result=MYSQL_QUERY(“INSERT INTO shoutbox (name,message,time)”.
‘VALUES ("’ . $_POST(‘name’) . ‘", "’ . $_POST(‘message’) . ‘", "’ . $time . ‘")’);
}
?>[/code]
und weiter gehts >.<
Fatal error: Function name must be a string in /users/ashley4fans/www/shout.php on line 8
[code]if($_POST(‘submit’)) //das ist line 8!
{
//use the PHP date function for the time
$time=date(“h:i d.m.Y”);
// inserting it into the shoutbox table which we made in the mysql statements before
$result=MYSQL_QUERY(“INSERT INTO shoutbox (name,message,time)”.
‘VALUES ("’ . $_POST(‘name’) . ‘", "’ . $_POST(‘message’) . ‘", "’ . $time . ‘")’);
}
?>[/code]