I wanted to create a shout box,
I created 4 files: shoutbox.php, connect.php, show_shout.php and box.htm.
--------------------------------------------------------------------------------------------------------
shoutbox.php:
--------------------------------------------------------------------------------------------------------PHP Code:<?php
include("connect.php")
if(isset($_POST["posted"]))
{
$name = $_POST["name"];
$message = $_POST["message"];
$time = time();
$ip = $_SERVER["REMOTE_ADDR"]
$check_name_length = strlen($name); // checks length
$check_message_length = strlen($message); // checks length
If($check_name_length => 30) || if($check_message_length => 250) // if statements for length
{
echo "Please fill in the textboxes properly.";
}
else {
mysql_query("INSERT INTO shoutbox( id, ip, name, time, message) VALUES ("NULL","$ip", "$name", "$time", "$message")") or die ("Failed to add shout");
}
}
?>
connect.php:
--------------------------------------------------------------------------------------------------------PHP Code:<?php
$connect = mysql_connect("localhost","shachi","thisistest") or die("Failed to connect to host")
$db = mysql_select_db("freemys_shachi") or die("Failed to connect to database");
?>
show_shout.php:
--------------------------------------------------------------------------------------------------------PHP Code:<?php
include("connect.php");
$query = Mysql_query("SELECT * FROM shoutbox DESC id LIMIT 5");
while($r = Mysql_fetch_array($query)
{
$time = $r["time"];
$name = $r["name"];
$message = $r["message"];
}
echo "Shout by $name at $time:";
echo $message;
?>
box.htm:
--------------------------------------------------------------------------------------------------------HTML Code:<html>
<body>
<form method="POST" action="shoutbox.php">
Name: <input type="text" name="name"> <!--//field with the name "name"--><br>
Message <input type="text" name="message"> <!--//field with the name "message"--><br>
<input type="hidden" name="posted" value="true"> <!--// hidden form field containing value "true"--><br>
<input type="submit" value="Shout!">
</body>
</html>
When I tried to post from box.htm it shows a parse error:
Parse error: parse error, unexpected T_IF in /var/www/shoutbox.php on line 3
I don't know what the problem is, someone plz help. :confused:

