Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

online file change problem

fopen fput fclose HELP



3:11 am on May 10, 2003 (gmt 0)

10+ Year Member

I am working on making a tool for my internet illiterate mom to update something on her website. The file is intended to update the "news" section of the website. For somereason, the variable wont echo into the second document. Can anyone please debug this code?

File: newsupdatepage.php

<title>UPDATE NEWS</title>
<body bgcolor="black" text="lime">
<style type="text/css">
.news {
background-color: #000099;
border-color: #000099;
border-style: solid;
color: #ffff00;
<form action="changenews00001.php" method="post">
<h1>UPDATE PAGE</h1><br>
<nobr><input name="$newnews" class="news" value="News goes here..."></nobr>
<input type="submit" value="CHANGE" class="news">

File: changenews00001.php

echo "<p>Update mode.</p>";
$cnf = fopen("updates.php","w+");
$newnews = stripslashes(htmlspecialchars($newnews));
fputs($cnf,"<? ");
fputs($cnf,"\$newnews=\"$newnews\"; ");

Note: all that update.php is, is a file to store the variable "$newnews". index.php is the index page of her site (all of this is in a root dir).

all help would be greatly appreciated.

[edited by: jatar_k at 3:25 am (utc) on May 10, 2003]
[edit reason] problems with smileys [/edit]


3:30 am on May 10, 2003 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Welcome to WebmasterWorld penguinpage,

for one this

<input name="$newnews" class="news" value="News goes here...">

should be

<input name="newnews" class="news" value="News goes here...">

and this
fputs($cnf,"\$newnews=\"$newnews\"; ");

puzzles me a bit not quite sure what that is. I could be a little daft but the syntax looks awry. I was going to post it properly then got confused as to what you were trying to do. What exactly are you trying to write there?


8:48 pm on May 10, 2003 (gmt 0)

10+ Year Member

fputs($cnf,"\$newnews=\"$newnews\"; "[smilestopper]);

this is supposed to use the new news value from the form, and write it into a php file. the resultitng php file would look like this

<? $newnews="";?>

with the news from the form between the quotes


1:05 am on May 14, 2003 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

why not just write the content of the var to the file and then include it?



3:27 am on May 14, 2003 (gmt 0)

10+ Year Member

If you wanted the contents of $newnews available as a variable in some other script, instead of includ()ing it you could maybe do this:

<? $newnews=join('', file('./updates.php'));?>

in whichever script you wanted to use $newnews. It's horribly inefficient, but nice and easy.


Featured Threads

Hot Threads This Week

Hot Threads This Month