FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


error in my PHP script





golles
I use a PHP script to load ans save (edit) a txt file.
but I have an error in my save code, it changes adds \ to the textarea
example:

Quote:
<a href=\'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/vb6anchor.asp\' target=\'_blank\'>MSDN</a>, gepost door <a href=\'mailto:golles@gmail.com\'>golles</a>

I hope someone can help me with my code:

Code:

<?php include 'login.php' ?>

<?php
$fn = "link.txt";
$content = stripslashes($_POST['links']);
$fp = fopen($fn,"w+") or die ("Fout met het openen van het bestand!");
fputs($fp,$links);
fclose($fp) or die ("Fout met het sluiten van het bestand!");
?>
<br><br><br><br>
<center>De pagina is met succes opgeslagen<br><br>

it saves the text in an text area, I think it is usefull to have to code of the other page so here it is:

Code:

<?php include 'login.php' ?>
<html>
 <head>
  <title>Admin pagina</title>
 </head>

 <body>
  <form method="POST" action="linksSave.php">
   <textarea name="links" rows="30" cols="100">
<?php $fn = "link.txt"; print htmlspecialchars(implode("",file($fn))); ?></textarea><br>
   <input type="submit" value="Opslaan" name="Save">
  </form>
 </body>
</html>


the first code is linkSave.php but I think you allready knew that Wink

I think the error is in this line:
Code:

$content = stripslashes($_POST['links']);


thanks in advance!


//golles

[edit]afther a good read I noticed they come in fron to a ', what to do?[edit]
dandelion
I guess the problem is that you put into the file the $links variable itself instead of its stripslashed copy $content.
Code:
<?
fputs($fp,$content);
?>
golles
dandelion wrote:
I guess the problem is that you put into the file the $links variable itself instead of its stripslashed copy $content.
Code:
<?
fputs($fp,$content);
?>

thank you verry much Smile
I changed the content to links because the example script on the web had content and the name of the textarea was also content, and my text area is called links.
but what I forgot to tell was that I'm a n00b at PHP Razz
thanks you again Very Happy


//golles
Related topics
Phoenix free PHP scripts
how can i make a php script for enter username and password?
Inserting data to MYSQL with a PHP script
Running a "Hello World" php script
[PHP] Running Cron Jobs Via PHP Script
Simple PHP script not working
PHP Script- How can we install it
I need a VERY simple php script
PHP Script needed
Logging systeem php script
Preventing bad PHP script calls
array check box on php script using $_POST
Please help. php script installation error
Uploading an Image using PHP script - RESOLVED
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.