Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Editing And Deleting Flat Text Files


I am working on a php news script that uses text files for it's DB. I have most of it done except for the ability to edit or delete the articles in the DB.

I have only been coding for about a week now so my skills are pretty limited and I have not found any tutorials that cover this issue so if anyone could be kind enough as to show me how this is done I would be most greatful....




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Editing/Viewing Flat Files
I'm making a simple events listing; where the user logs in, adds events (in fields, pull downs, textarea, etc) and then posts it (via a flat file). Now, first question, how do I make it so tha the characters (such as ' or ") display without a / next to them (I'm sure it's a string command, not sure which one to use).

Second, how can I make it possible for them to view inside a textarea and edit, but not have it show the HTML code that is generated by their creating the event (their field entries are nested within tables, etc). Is that possible via some sort of find and hide thing (I don't want them to see the <table><td>, etc tags, but I don't want those tags to disappear when they want to edit their events).

Editing And Handling Vars From Text Files
I have a config file like that

a=12
b="some other values"

I want to handle these vars for my php program and also be able to edit these vals.

Editing Text Files In Form Textareas?
I want to pull text files into a form text area and then edit them. to open the file I am using:

$toEdit = fopen ("../content/concept.txt", "r+"); which does not work at all unless I change the path to c:xxxxxxxxxx but I dont want to do that. If I use the hard coded path I get permission denied, if I change the file to read only it seems ok - however, I want to load it into a form textarea? Cant work this out, then I want to save it.

Its just to update a simple text schedule. there will be no special characters that need escaping etc. This is probably a pretty basic question but I have been asked to do this ASAP and my attempts so far have just confused me!

Deleting Lines From Flat File
I am trying to display all the news items in my flat file with 'delete' links (<a href="managedeletenews.php?action=delete&id=$key">Delete[/url]) that call the same page to strip out the line and rewrite the file.

However, when the delete link is clicked nothing happens (except the page's address changing from "managedeletenews.php" to the above.

Am I using the references to the $id or $key variables incorrectly?
Is it something to do with the undefined $action variable?
Or is it something else??
BTW, the embedded styles for the delete link - shown below - don't seem to be throwing up any errors. Code:

Deleting Not Working - Flat File Database
I have to decrypt the $email variable in order to delete from a flat file database. I am not sure how to do this... It decrypts it and trims it to display on a select field, but I don't know how to make it delete. Code:

Deleting Strings Of Data In Flat File Db
I have a flat file database with some data stored in it. I have a script which uploads new data to it and want to have a script where by i can delete specific rows of data.

I have a 'delete' link which when clicked is meant to delete that specific row of data which works when each columb of data is a single word with no spaces but when i have strings of data it won't delete.

Editing And Updating Text
I'm trying to create a text editing and updating capability to help
someone who wants to maintain content on a web page without having to
know any HTML or use a web authoring tool and FTP'ng the contents.
I've already created a screen whereby the person can create new
content with a PHP program that inserts into a MySQL table. But, I'm
having a little trouble in creating the edit/update functionality.

I created an edit screen called "teach_edit.php". Based upon some
search parameters on another HTML screen, it retrieves the appropriate
text from the database. It seems to allow on screen editing.
However, when I hit the Submit button, nothing happens. It's supposed
to call another program called "teach_update.php". Here's the code
for it.

<HTML>
<HEAD>
<TITLE>Teaching Edit Program</TITLE>
</HEAD>
<BODY>
<?php

@ $db = mysql_connect('localhost', '<db name>', '<password>');
if (!$db)
{
echo "Error: Could not connect to database. Please try again
later.";
exit;
}
mysql_select_db("<db>");

$query = "select * from albert where ".$searchtype." like
'%".$searchterm."%'";

$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$title = $row['title'];
$teaching = $row['teaching'];
$teaching = wordwrap($teaching, 60, "
", 1);
$teachnum = $row['teachnum'];
}
if ($result)
{


Editing Files In A &lt;textarea&gt;
I've written this program to let me edit ASCII files on my server in a <textarea>. However, if the file that is being edited contains a textarea within it, then I get problems.

what I want to do is read this file into the textarea but I want to convert all of the < and > characters to &lt; and &gt; 's. I figgered you'd do this through Regular Expressions: however these are poorly documented in the PHP book I have, though the Perl book I have tells me how to do this. Could someone tell me how to do this, IN PHP! Code:

Rdms Vs Flat Files
Forgive me if this subject has come up in some form, but I was wondering if there is any validity for using flat text files (encypted or other wise) as opposed to a database system.

I have used MySQL and PostgreSQL with PHP extensively, and lately I have been seeing that there are some situations where regular files would work best. One example is a content management system.

I would assume this is the case because the threshhold between the convenience of the db system and the overhead of using it to deliver content on a busy site if quickly reached, and soon becomes apparent that a flat file based system would be much easier and more scalable as the site grows.

MySQL Vs Flat Files?
I'm in the planning phase of a new website and i just want to know what leads to the least server load, when you have REALLY many visitors.

What I want to create is a new type of online community site, and I wonder if there would lead to less server load if I combine MySQL(for the search functions, and parts that change often) and flat-files(for the parts that don't change that often, like profile text, image-sites etc.). The only thing I want to know the difference of is what solution would lead to the least serverload?

Replace All From This To That. - Flat Files
I am experimenting a little using Flat files now. I have a file that looks something like this:

<?php
// variable
$var = "asdasd";

// array
$array = array("lala", "lalal");
?>

How can I replace the $array's content with for example "array("blablabla", "blabla")" without knowing the old value of it?

Editing Text File With A PHP Form
I am trying to do something with PHP that i am sure is pretty easy. But not sure myself how to do it.

I have a file that i want to pull into a simple HTML Form text field. From that field the person can just add in content or remove content.. Click "Update" .. And it will write the new content out.. Overwriting the old file if need be.

Editing Multiple Text Elements
I'd like to edit multiple rows with one click by the user. Basically I'd print out <input type=text name=fieldname value=$value> for each record in the table. When the user clicks submit PHP will then loop through each row updating where necessary.

Large Gap When Editing Text From Database
My first PHP project is a very simple blog system and I have a page which lists blog entries. This page provides a link to the edit page, when clicked opens the edit page and inserts the values from the database into the from. My problem is that it puts in a large gap of two tabs and two spaces the start of the from. The challenging thing is that if I slick submit, the gap is not put into the post.

Flat Files And User Athentication
I am trying to think of a secure way in which users can update their info that is being displyed on a site. I only have flat files available to me as a "database" and we cannot have just any old person come and start editing everyone's info. So I need some form of user authentication whereby the user can login and upload new info when need be.

Relating Fields In Flat Files
I am trying to relate two flat files by a common field - I know this can be done easily in MySQL but I want to use flat files.

For eg I have a Categories file that contains Category Id and Category Description. I have a Product file that contains Category Id, Product Id, Product Description. The files are related by Category Id ie a product can belong to only one category but a category can have many products.

How do I code this relationship between the two files in PHP. I have looked for examples on the web but with no luck. For example if I wanted to display all the products belonging to a category in a neatly formatted table - what is the best way to do this?

Get_meta_tags Work On Flat Files?
I am wondering if you can use the get_meta_tags function on flat files. Because while i'm trying to do it i get an error that says:

Warning: get_meta_tags("") - Success in /home/user/public_html/test.php on line 47

Unescaping Characters In Flat Files
I'm making a modular website using flatfiles (can't use mysql) and I realized I've never done a flatfile before (too much mysql) and I realized I'm having issues with quotes
like if i say "data" it returns as "data" I know i can do a stringreplace on the out put to remove slahses, but there is a lot of characters to escape any tipsideas on making it easier on myself?

Help? How To Create Next Buttons When Using A Flat Text Database
Ok, I know the code below does not work but I am wondering about the logic...

1 How do I just print 10 rows.
2 How do I get the buttons.

You get the Idea. Anyway, I would like to know if anyone has done this with text files. I always see mysql as examples but nothing using a flat text database.

<?
$maxResults = 10;
$datafile = "sometextfile.txt";

$rows = @file($datafile);
for($size=0;$size<count($rows);$size++) {
$rows[$size] = chop($rows[$size]);
$coll = split("|",$rows[$size]);


// print something

}
if ($size > 0) {
$currPage = $size / $maxResults;
if ($currPage > 1)
print("<A HREF="test.php" >['prev']</A>");
for ($i = 0; $i < $size / $maxResults; $i++) {
if ($currPage == $i + 1)
printf("<A HREF="test.php"> </A> ",$i + 1);
else
printf("<A HREF="test.php"> </A> ",$i + 1);
}
if ($currPage < size / $maxResults)
print("<A HREF="test.php">['next']</A>);
}
?>

How To Sort A Flat Text File By A Particular Field
I have created a flat file database to store contact information on my friends. The fields are 'firstname', 'surname', 'job title', 'address' etc What I am trying to do is be able to display a sorted list of my friends based on a particular field eg 'sort by surname'or 'sort by address' etc

Each row in the file ends with a '' and each field in each row is separated by a ' '.

I have come to the conclusion that I need to use the array_multisort function but cannot find any examples of taking information from a flatfile database and using array_multisort to sort and display based on a particular field. This is how far I have got but I am now stuck as to where to go from here? I have read the php manuals but it does not appear to improve my understanding of what needs to be done. Code:

Upload Image And Save It As Flat Files
how to upload image and save it to a directory and then edit or delete it like making database in flat files .

Site Stats, Php/mysql OR Flat Text File?
I'm have a cms  and I want site stats built in, thus apache's stats or cpanel etc don't cut it for multiple users.

I have a working stat query below, the problem is, in a short time 12 hours, it's grown to 109k with 500 records.
now I'm not adding a row for every person, I create a session, and if they already have a row, I update clicks (page clicks) as you can see.

still, it's big, the bots are eating it, so I figure, why not just create a separate table for bots, with 1 row per day and a click count. there, smaller. but with multiple users, and lots of normal hits, this will still grow quite large very fast!

so I'm wondering if flat text files would be a better solution? but perhaps opening and writing to a text file constantly gets very slow? I'm confused. Code:

Updating Flat Files, Using Fopen, Fwrite, And Fclose Techniques.
Here is a function I wrote that will handle my password changes for me. There's the regular form of putting in your current password, and typing your new password in twice. This form will take the username, current password, and the two new passwords typed in and process the information. $admin is basically an administrative override if the administrator needs to change the password for a user. Code:

Deleting All Files
Is it possible to delete all files in a folder using unlink() or something similar?

Deleting Files
The below should delete files from a dir older than a week. I set the $dtime to 0 to test the script but it deletes nothing. What is wrong? Code:

Deleting Files
I'm using different files to store some arrays to make administration of a very small job-logger very easy. I currently read the file, remove the element to be deleted, delete the whole file, and write the file again without that element. Is there a way to remove a single element out of that file without deleting the whole file?

Deleting Files
I'm trying to modify this script to remove files that end with %enlarged.jpg or %enlarged.gif or %enlarged.png, can someone help with the if statement, I've tried several things, of which, nothing is working: Code:

Deleting Files
I have some script that takes an album id and deletes that album and the specific photos in that album. The code does run. The problem is that an error message i set to echo appears saying error deleting photo once the page automatically refreshes. When i check the image folder the images actually have been deleted. Code:

Deleting All Files With A Certain Prefix
I'm using php 4.4.4. Given a particular directory, I want to delete
all the files that begin with the variable "$prefix". What is the
simplest way to do this?

Deleting Files From A Folder...
I have a folder with many pictures in it.
All have the name like: HHMMDDMMYYYY.jpg

H-hour
M-minute
D-day
M-month
Y-year

Now I want to delete all pictures which are older than now()-7days.
How Can I do it? In SQL would be no prob but with file deleting is problem.

Deleting All The Files In A Directory
Using PHP 4, what are the shortest amount of lines I can write to
delete all the files in a given directory?

Deleting Files From A Server
As part of a project I want to allow users to save files to a server or delete files from a server. I have the uploader working fine, but i have no idea how i would delete the file from the server.

Attaching/deleting Files
I'm trying to create a tree where you can access files from the tree. The files will NOT be stored in the database, but on the server. I have a web forum eg, where they store the title of the message in a separate table compared with the message which is another table.

How do I store the files and show them on the tree, and how will the system know where to get the files from, if they're not in the database?

Deleting Files Onclick
I have an app that lists out the files on a server.  I have a checkbox at the end of each file.  You can check any number of files.  Then I have a link at the top that says "delete selected files."  Could someone just tell me how to write the code to delete the files in general?  I'm not asking for all the exact code, just the concept.  I assume I will be calling a php or javascript function with the "onclick" method. Code:

Deleting Rows On Text File
I have a function where it writes data on a text file with an assigned id. For example, the text file looks like:

data.txt

1|Hey
45|Hi
76|Hello

What I'd like to do is add a function that will allow me to use the specific line that start with the id. For example:

delete.php : On this file I will pass the id number and based on it, the function will go to the data.txt file and delete the specific row. So if I pass the id=45, it will remove that row ONLY and the data.txt file will look like below after removal:

1|Hey
76|Hello

Creating And Deleting Folders And Files
Hi to Everyone.

After creating trought http a organize number of files and folders. I'm not able to delete them, not even trought an FTP Software like Cute FTP. It replies "Could not delete xxxxx.html".

Error Deleting Uploaded Files
I have a configuration script which creates a directory on the server, directory used for uploading files. Everything works fine (creation of the directory, uploading) but when I try to delete an uploaded file from this directory using total commander as ftp client I get the following error: "550 Delete operation failed".

The used code is something like this:

$cursuri = "../cursuri";
@mkdir($cursuri, 0777);

Note: if I use total commander "chmod 777 cursuri" I don't get any problems.

Deleting A Line Of Text From A Txt File From A Form
How can i delete a line of text from a .txt file using a form?

because i have a form right now that saves information from a form to a txt file for news, now i need to know how to make it so i can delete it from a form.

also, if you know how, how do you overwrite lines of text in txt files from a form?

Deleting Files In A Folder Modified Before Certain Date
I use a cache system that requires creation of files in a folder .

Now , what i need to know is how can i delete files created say 3 days ago.

So that the cache remains fresh.

The directory contains around 20,000 files , about 10,000 are generated each day (if they dont exist)

So getting info about the each file after using opendir will cause the server to slow down.

Zend Studio 3.5.2 Possibly Deleting Files?
At work I'm using Zend Studio 3.5.2 to develop PHP files on my Win2K
desktop machine. I've got Zend Studio setup with a secure FTP (SFTP)
connection to a RedHat Enterprise Linux machine. The files I'm editing
'live' on a Solaris machine and the linux machine mounts them through
NFS. I actually access the files through a symbolic link to the mount
point on the linux box. A little complicated I know, but it does work.

I've been having a random problem lately. Every once in awhile (every
couple of weeks) when I'm in Zend Studio and have a few (not all) php
files open, all the files in the directory where I'm working get
corrupted. They all get turned to a file of nothing but nulls (zeros)
and the files are exactly 512 bytes long. This concerns me because it
seems to only happen to me even though other people work on PHP files
in other directories. The difference is that I'm the only one who uses
Zend Studio regularly. I can't see how that would be a problem since
the connection to the files is through SFTP and is essentially
stateless and connectionless. Has anyone else seen this problem or have
any insight about what might be going on?

Deleting Lines From Top Of A Large Open Text File
I am splitting up one huge text file in several smaller files to prepare them for database processing. So far I tested it with files up to 100MB and everything works fine.

Now here's my question: To optimize my script I would like to incrementally remove all lines form the original file which have already been copied to the smaller file.
This would speed up reading the original file in each loop.

Unfortunatelly I couldn't find a way to remove/delete lines from an open file. Of course I could read the whole file, delete the lines and then write it back. But for files bigger than 1 GB this doesn't seem to be a good idea....

Deleting Files Using Unlink [function.unlink]: Permission Denied
I have a record in the db and a picture file name recorded with that record. I am writing a deletion routine which checks that file name and is supposed to delete it using unlink.

Although it reports the correct directory and file name, I received the following:

Warning: unlink(/home/pab/html/pics/test.jpg) [function.unlink]: Permission denied

I checked my permissions and the file is set at my user name and 666.

Does anyone know why this won't work or maybe another way to delete the file?

Batch File Deleting And Folder Deleting
I have a folder in my web site where I used php to create and copy in files. but now I can't delete them easily. The only way I know how that is possible is through php. I get an error the following ftp error:

550 th: Permission denied
I had the chmod() set to 0777 on every file and folder. But I still seem to loss control over the files when I try and do things with them through other means.

I think it is because the user I use to access the files via ftp a diffrent user. So I tryed to add a function with chown() for the new files I was posting and uploading. It didn't work on those new files. so it looks like the only thing I can do is use the unlink() function which deletes the files fine.

The only problem is now I have something like 100 sub directories all with files in them. I need to figure out a way to batch delete them. I can't find a script that goes through and finds all file contents including all sub directories and unlink those things.

I found some that will use a for loop to list out the contents of a folder but it is just files. No sub directories. Any body got any ideas on which functions I should use or know where a script is that I can base mine off of.

I am not sure how to approach this since what I tryed with chown and chmod has failed thus far. I currently have no code and am starting from scratch on this batch flushing of my directory.

Parsing Text Files
I have a little brain freeze going here. I can't remember how to do this.

I'm trying to parse a text DB file and seperate all information in it so that I can insert them into MySQL as seperate values in seperate fields. for example,

1 | howdy | there

That would be three peaces with three different fields in MySQL. I know I've done this before but can't for the life of me figure out how I did it. All I need is somebody to jog my memory and get that little brain of mine weorking again.

Extracting Text From PDF Files
I need to extract the text from a PDF file for storage in the database.
Is there a way to do this in PHP?...

Upload Text Files
Its only once you've got loads of content that you start filtering what people see based on their prefferences. To get lots of content you need to get people to upload text files which end up on web pages extending your site.

Cookie Text Files
I just added some cookies to my page, and they work fine, but I just wanted to know what the lines mean when I view the file in Notepad. PHP Code:

How Get Differences Between Text Files:
I have two text (configuration files) and I'd like to get the difference between these files.
I'd like something like "diff" in linux or differences in wiki.
how can I do?

Extracting Text From Pdf Files
with how to extract text from pdf files using PHP or
ColdFusion?


Copyright © 2005-08 www.BigResource.com, All rights reserved