fwrite problems

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
coolenta
Forum Newbie
Posts: 6
Joined: Wed Nov 22, 2006 7:22 pm

fwrite problems

Post by coolenta »

I have desighned a online editor for my site. There is a problem with it however. When i use linux with apache 2 installed and php 5 it messes up the link html. It turns this <a href="http://www.google.com">google</a> Into This <a href=\"http://www.google.com\">google</a>. I am using the fwrite function. When i try this on my windows server running an early version of php this does not happen. Does anyone Know how to fix this?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

stripslashes()

though I'd look into it further and figure out why they're being added in the first place.
coolenta
Forum Newbie
Posts: 6
Joined: Wed Nov 22, 2006 7:22 pm

Post by coolenta »

Burrito wrote:stripslashes()

though I'd look into it further and figure out why they're being added in the first place.
This does not work, Could this possibly be a problem with the linux txt manegment it self?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

post code please of insertion and retrieval of data
coolenta
Forum Newbie
Posts: 6
Joined: Wed Nov 22, 2006 7:22 pm

Post by coolenta »

Jcart wrote:post code please of insertion and retrieval of data
here is the code with the errors
retrival code

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>saving changes....</title>
<?php

$page = $_GET ["page"];
$input = $_POST ["h"];
$fp = fopen("$page.txt", "w+");
fwrite ($fp, "$input");
fclose ($fp);

print "<meta http-equiv='refresh' 

content='1;URL=/index2.php?id=$page'>

</head>";
print "If your browser does not automatically redirect you in 5 

seconds,
click <a href='/index2.php?id=$page'>here</a> to go to the new site.";
?>

</body>
</html>


send code
here is the method of inserting the html

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Edit A Page</title>
</head>
<body>
<?php
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
if ($pass=="this is my password"){
$e = $_GET['page']; 
print "<input type=submit value=edit-webpage></p>";
$filename = "$e.txt"; 

if (file_exists($filename)) { 
   $file = fopen("$e.txt", "r") or exit("file is not in global data base.");
print "<form action='1ge.php?page=$_GET[page]' method='post'>
<textarea name='h' rows='40' cols='140'>";

//Output a line of the file until the end is reached
while(!feof($file))
  {
  echo fgets($file). "";
  }
fclose($file);
print "</textarea>
<input type=submit value=edit-webpage></p>"; 
} else { 
   print "<form action='1ge.php?page=$_GET[page]' method='post'>
<textarea name='h' rows='40' cols='140'> File does not exist you can make it now!!! $filename</textarea>
<input type=submit value=edit-webpage></p>";
}
}
else 
print "incorrect password";
?>
</body>
</html>
Last edited by coolenta on Wed Nov 22, 2006 9:29 pm, edited 1 time in total.
Post Reply