/    Sign up×
Community /Pin to ProfileBookmark

Interesting Error

so I’m trying to make it so that I can open a file, and display it in a textarea. I want to then be able to edit it and save it. I have done this and the file is created successfully. The only weird thing is, no matter what file I use, it always deletes code from the top of the page.
When it displays my “index-generic.php” file in the text area it should be

[code=php]
<?php
require(“header.php”); //Edit this

if (isset($_SESSION[‘id’]))
{

print ‘<title> || ‘.$_SESSION[‘un’].'</title>’; //Edit this

print ‘<div align=center>’;

$d = opendir(‘.’) or die($php_errormsg);

$jpg = explode(“.jpg”,$f);
[/code]

but instead it comes out as

[code=php]
<title> || ‘.$_SESSION[‘un’].'</title>’; //Edit this

print ‘<div align=center>’;

$d = opendir(‘.’) or die($php_errormsg);

$jpg = explode(“.jpg”,$f);
[/code]

the code that is reading the file is as follows:

[code=php]
$fileName = ‘blank_things/index-generic.txt’;
$fileHandle = fopen($fileName,’r+’) or die(“Can’t Open File”);
$data = fread($fileHandle,filesize($fileName));
[/code]

It’s weird, to me, because it’s just not printing the entire file in the text area, but I can go to the file ( I made it a .txt so nothing would execute) and it was all there. At first I was confused because the filesize was different than on my computer, but I asked a friend (a network admin) and he says that that can happen, depending on settings. So….I dont know how to fix it..I think thats enough, if not I’ll post more (I just didn’t want to clog up the post with the entire script becuase the rest doesn’t matter)…I think…
anyways, thanks in advance for the help,
~EMH

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 12.2006 — You might need to use htmlentities() to output the file data to the form, perhaps?
Copy linkTweet thisAlerts:
@emhufafauthorJul 12.2006 — I'll try that and get back...

thanks ^_^,

~EMH
×

Success!

Help @emhufaf spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...