yo copio tu codigo tal cual y no me resulta ni un error
crea otro archivo y solo coloca el siguiente codigo tal cual
Cita: <?php
$error=array();
//validacion
if(strlen($_POST['titulo'])==0){ //strlen te dice cuanto mide una variable
$error['titulo']="si";
}else{
$titulo=$_POST['titulo'];
}
if(strlen($_POST['nota'])==0){
$error['nota']="si";
}else{
$nota=$_POST['nota'];
}
//cierre validacion
if(count($error)>0){
if($error['titulo']=="si"){
echo "<h3> Error en el titulo </h3>";
}
if($error['nota']=="si"){
echo "<h3> Error en la nota </h3>";
}
echo "<h3> ERROR: ¡NO SE GUARDO! </h3>";
}else{
if(file_exists("mensajes.txt")){
$db=unserialize(file_get_contents("mensajes.txt")) ;
}else{
$db=array();
}}
$fila=array();
$fila['titulo']=$titulo;
$fila['nota']=$nota;
$db[]=$fila;
file_put_contents("mensajes.txt", serialize($db));
echo "<h1>GUARDADO</h1>";
?>
<form id="form1" name="form1" method="post" action="#">
<p>
<label for="titulo">Titulo</label>
<input type="text" name="titulo" id="titulo" />
</p>
<p>
<label for="nota">Nota</label>
<input type="text" name="nota" id="nota" />
</p>
<p>
<input type="submit" name="button" id="button" value="Guardar" />
</p>
</form>