PDA

View Full Version : What wrong with my code ARGH! + Rep



aster01d!!!!
10-07-2006, 07:15 PM
The code is for a shoutbox +Rep to anyone who can help :0




<?
include "config.php"; // include the config
if($_POST['submit']){ //checks if the form was submitted
$name = $logged[username]; //posts the username
$shout = $_POST['shout']; //posts the shout
$insert = MYSQL_QUERY("INSERT INTO shout (name,shout)".
"VALUES ('$name', '$shout')"); //inserts into the database
}
$find = mysql_query("select * from shout order by id desc limit 5"); //finds the shouts order by id
while($r=mysql_fetch_array($find)){ //loop's the shouts
$name = $r[name]; //name
$shout = $r[shout]; //shout
echo "<b><font size='10px' color='#FF3380' face='verdana'>$name</font></b><br><font size='10px' color='#FF3380' face='verdana'>".$shout."</font><p>";
if($logged[username]){ //if the user is logged in display the form
echo "
<form method=post>
Shout:<br/>
<textarea name=shout cols=28 rows=4>Message here</textarea><br/>
<input type=submit value=Shout name=submit><br/>
</form>";
}
?>

Colin-Roberts
10-07-2006, 07:20 PM
what error are u getting?

Eric30
10-07-2006, 07:21 PM
Well what is it not doing? Any error messages?

I can see a few things, but if u dont post whats wrong how is anyone ment to help.

aster01d!!!!
10-07-2006, 07:26 PM
Parse error: syntax error, unexpected $end in /home/johno/public_html/shout.php on line 23

Eric30
10-07-2006, 07:27 PM
<?
include "config.php"; // include the config
if($_POST['submit']){ //checks if the form was submitted
$name = $logged[username]; //posts the username
$shout = $_POST['shout']; //posts the shout
$insert = mysql_query("INSERT INTO `shout` (name,shout) VALUES ('$name', '$shout')"); //inserts into the database
}
$find = mysql_query("select * from shout order by id desc limit 5"); //finds the shouts order by id
while($r=mysql_fetch_array($find)){ //loop's the shouts
$name = $r["name"]; //name
$shout = $r["shout"]; //shout
echo "<b><font size=\"10px\" color=\"#FF3380\" face=\"verdana\">".$name."</font></b><br><font size=\"10px\" color=\"#FF3380\" face=\"verdana\">".$shout."</font><p>";
}
if($logged[username]){ //if the user is logged in display the form
echo "
<form method=\"post\">
Shout:<br/>
<textarea name=\"shout\" cols=\"28\" rows=\"4\">Message here</textarea><br/>
<input type=\"submit\" value=\"Shout\" name=\"submit\"><br/>
</form>";
}
?>


I also cleaned it up a little

aster01d!!!!
10-07-2006, 07:31 PM
Much appriciated + rep :)

Want to hide these adverts? Register an account for free!