String error thing?

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

Post Reply
Cucumberdude
Forum Newbie
Posts: 14
Joined: Sun Dec 12, 2010 11:53 pm

String error thing?

Post by Cucumberdude »

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
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: String error thing?

Post by Jonah Bron »

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>");
Post Reply