PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Cucumberdude
Forum Newbie
Posts: 14 Joined: Sun Dec 12, 2010 11:53 pm
Post
by Cucumberdude » Wed Dec 15, 2010 7:50 pm
Code: Select all
<?php
$input = $_POST['msg'];
$name = $_POST['name'];
$input = strip_tags($input);
$name = strip_tags($name);
if($name == "")
{
$name = "Anonymous";
}
if (strlen($input) > 250 || strlen($name) >30)
{
header( 'Location: xxx' ) ;
}
else
{
$date = date('c');
$fileHandle = fopen('chatlog.txt', 'a')
fwrite ($fileHandle, '<br>@$date $name said:</b> $input<hr>');
fclose($fileHandle);
}
?>
Simple chat thing. Another page sends the _POST from an html form.
Get this error on submitting:
Parse error: syntax error, unexpected T_STRING in /home/sterli41/public_html/eStables/Chat/post.php on line 22
Jonah Bron
DevNet Master
Posts: 2764 Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California
Post
by Jonah Bron » Wed Dec 15, 2010 7:56 pm
You forgot the semicolon at the end of line 20. Also, the variables will not be inserted with single-quotes. They must be double-quotes.
Code: Select all
$fileHandle = fopen('chatlog.txt', 'a');
fwrite ($fileHandle, "<br>@$date $name said:</b> $input<hr>");