Page 1 of 1

String error thing?

Posted: Wed Dec 15, 2010 7:50 pm
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

Re: String error thing?

Posted: Wed Dec 15, 2010 7:56 pm
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>");