php script inserts 2 spaces into text area

I have a script that enables me to write text to a file.
But the php script inserts 2 spaces into text area, after it is saved.

I need to remove the 2 leading spaces.

Script:

<?php $saving = $_REQUEST['saving']; if ($saving == 1) { $data = $_POST['data']; $file = "kano.txt";
$fp = fopen($file, "w") or die("Couldn't open $file for writing!");
fwrite($fp, $data) or die("Couldn't write values to file!");

fclose($fp);
echo "Saved to $file successfully!";

}
?>

<?php $file = "kano.txt"; if (!empty($file)) { $file = file_get_contents("$file"); echo stripslashes($file); } ?>

That is because of the extra line breaks you put between and . This should now work:
[php]

<?php $saving = $_REQUEST['saving']; if ($saving == 1) { $data = $_POST['data']; $file = "kano.txt";
$fp = fopen($file, "w") or die("Couldn't open $file for writing!");
fwrite($fp, $data) or die("Couldn't write values to file!");

fclose($fp);
echo "Saved to $file successfully!";

}
?>

<?php $file = "kano.txt"; if (!empty($file)) { $file = file_get_contents("$file"); echo stripslashes($file); } ?>
[/php]

Thanks you

Sponsor our Newsletter | Privacy Policy | Terms of Service