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




Changing Data In Text Files


Is there an easy way in which I can edit values in a text configuration file? I am creating a form based interface to administrate a few text based config files. I can get the values from the file by parsing it line by line, but I cannot find an efficient way to edit data based on changes submitted in the php form. Is there any way to get to a position in a file and then overwrite any information?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Changing Text Colour
i had this script down but have modified it, somewhere along the way and can't see where, what i had was, if there were messages in the users inbox the word "Inbox" would go red, if there were unread messages in there the "Inbox" would go blue if there were no messages it would simple be black Code:

Changing Text On Page Via Dropdown Box.
I have a webpage that draws various text decriptions from a mySql database. The description displayed on the page is controlled via a dropdown box. Currently I am using Javascript with a dropdown box (onChange handler) to change the value of a textbox.

Can anybody think of a way that I don't have to use a textbox(with its' scrollbars and background)? How can I change the value of a php variable by changing the selected index of a dropdown box?

Changing An Image For Text/hyperlink
I have the following piece of code, which uses an image as a button. I want to remove the image and just have some text/hyperlink which has the same effect when clicked? Would someone please help and advise what needs to be changed...

<?php echo tep_image_submit('button_wishlist.gif', 'Add to Wishlist', 'name="wishlist" value="wishlist"');?> ....

Changing File Extension With Inc Files?
I know you can select which file extension PHP uses when ur installing PHP, but can you tell to use a custom extension after installation?

Changing Titles Per Page With Inc Files.
The way my script is set up now, I have an index.php which calls on inc files.  The problem is that each page (inc file) is using the title set in the php.index.

My goal is to have a title for each page.  I've looked and looked but can't find anything. 

Changing Variables By Clicking Text Link?
I have a page that I need to change variabels with, based on what link you click on the page.

Changing Data Type
I want to change data type of some variable, if it would be C++. following would be the code:

int $var;
$var=int($str);

i have two questions, how to declare $var as int in PHP, secondly how to cast a variable  like () in PHP.

Changing Data In Objectified Mysql Records
I am using this very slightly modified function found here:
http://us2.php.net/mysql_fetch_object
to make mySQL rows into objects of type $classname:

// This takes db result rows and makes real objects of $classname type
function &buildObj($result, $classname) {
while($row = mysql_fetch_assoc($result)) {
if ($row === null) return null;

/* Create the object */
$obj =& new $classname;

/* Explode the array and set the objects's instance data */
foreach($row as $key => $value)
{
$obj->{$key} = $value;
}
$objs[] = $obj;
}
return $objs;
}

This is called by a retrieve: function:

function retrieve($where) {
echo $query = "SELECT * FROM $this->table WHERE " . join(' AND ',
$where);
$result = mysql_query($query);
$rows =& buildObj($result, get_class($this));
mysql_free_result($result);
return $rows;
}

The problem I am encountering is that if I do this in my script:

$listing = new Listing;
$listings = $listing->retrieve(array('row > 1') );
foreach ($listing as $aListing) {
$aListing->address='xxxxxxxxxxxxx'
}
foreach ($listing as $aListing) {
print_r($aListing);
}

The value in $aListing->address is unchanged.

However if I do this:

$listing = new Listing;
$listings = $listing->retrieve(array('row > 1') );
foreach ($listing as $aListing) {
$aListing->address='xxxxxxxxxxxxx'
$newArray[] = $aListing;
}
foreach ($newArray as $aListing) {
print_r($aListing);
}

I see the update values in $aListing->address .

Changing Object Data In An Array Of Objects
In this sample script I create an array of objects. Print out their data
with print_r().Update their data with a sub called v_set(). Print out data
showing the chnages using print_r(). I push the altered objects into a new
array and print them out again, still see the updated data. Then I iterate
over the original array again with print_r and the objects lose the updates
and have their original data.

<?
for ($i = 0; $i < 1; $i++) {
$listingObj = new Listing;
$listings[] = $listingObj;
}

foreach ($listings as $aListing) {
echo "<h3>THIS IS IN SCRIPT IN ORIG ARRAY BEFORE VARS SET</h3>";
f_array($aListing);
}

foreach ($listings as $aListing) {
$aListing->v_set(
array(
'name' => 'Jane',
'address' => Ïă Ohce Ln.'
)
);
// HERE IS BUG: WHY DO I NEED TO PUT IN NEW ARRAY?
echo "<h3>THIS IS IN SCRIPT IN ORIG ARRAY AFTER VARS SET</h3>";
f_array($aListing);
$newArray[] = $aListing;
}

foreach ($newArray as $aListing) {
echo "<h3>THIS IS IN NEW ARRAY</h3>";
f_array($aListing);
}

foreach ($listings as $aListing) {
echo "<h3>THIS IS IN ORIG ARRAY, APPARENTLY NOT
ALTERED/UPDATED?</h3>";
f_array($aListing);
}

class Listing {
var $changedVals = array();
var $name = 'Dick'
var $address = ́« Echo Ln.'

function v_set($data){
foreach ($data as $key => $value) {
$this->$key = $value;
$this->changedVals[] = $key;
}
}
}

function f_array($array) {
echo '<pre>'
print_r($array);
echo '</pre>'
}

?>

How To Update Mysql Table Without Changing Existing Data
how to update mysql table without changing existing data.

Problems With Reading Data From A Text File And Inserting The Data Into DB
Ive been having problems getting this to work for 3 days now. Basically what im trying to do is read from a text file and insert the information into mysql. The text file is in this format:

"LuCyndi@infiniti.com","carol","kellerhals","109 veeder dr","las vegas","NV","89128","702-254-2061","45"
"the_prophet@att.net","a.","cohen","6794 e. bonanza rd","las vegas","NV","89110","702-463-6569","55"

I understand how to open files to read but im having problems turning each set of data into an array so i may insert it into mysql. If someone could please help it would be appreciated.

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?

Uploading Text Files
I'm somewhat new to this whole MySQL/PHP thing and need a little help.

My web hosting service uses phpMyAdmin and at the bottom of the screen
iis an area where I can upload a text file to populate a table.

I have a table named groups with two fields:
groups_idauto-increment primary
groups_name

So how do I create my text file to populate this table?

I'm going to use MS Notepad.

If it's set to auto-increment, do I need to include the number? If
so, does it start at 0 (zero)?

Would the file look like:

0,students
1,faculty
2, staff

or just

students
faculty
staff

(though I can't image that working).

Creating Text Files On The Fly
What I want to do is allow a logged in user to download a text file version of the list they are viewing on the screen. So if they are viewing the Paid list of users, there should be a button on that same page that says Download To Text File, and when clicked, the user is prompted to download a text file version of the list.

Text Files Hit Counter
I have a script that I am using for text file based hit counter. I have been noticing that my the original hit count, in my text file has been fluctuating from the original amount to a very low amount. What is causing this and is there a good way to fix it? Code:

Create Different Text Files
I need to create a different text file every time a user registers. Currently every time a user registers there details are sent to "users.txt". So all user details are in the same text file. I would idealy like each text file to be named after the username registered. Here is the code currently being used:

$username = $_POST['username'];
$password = $_POST['password'];
$data = "$username, $password /n";

$fh = fopen("users.txt", "a");
fwrite=($fh,"$data");
fclose=($fh);

Creating Text Files..
I want to set my access rules to 0777 so that I can delete the text file via script if I need to. I already set the folder to 0777 when I created it.. now I just need the text files. How would I set the access to 0777 when I create the file? This is what I have right now...

$text= "this is text.";
$fileName = "examplefolder1/example.txt;
$handle = fopen($fileName, 'w');
fwrite($handle, $text);
fclose($handle);

Is there some way to do it in that statement?

Text Files Into Array
I'm trying to read a text file that has a bunch of names in it into an array so that I can output that array to a comma separated format. My problem is this, I do not know how to make a file go into an array, I've tried the explode function, but all that does is spit out  "Resource ID"

the format of the file is "1. FirstName LastName" with line breaks so the next line is "2. NewFirstName NewLastName", and so on...

Indexing Text Files In A Folder
I'm newbie on Php. I cannot write codes but only modify.
I need a code doing this:
I'll put text files in a folder like file1.txt,file2.txt ...
I want to search this files, list most recent 10 and if files

call, script will put into the site design with <pre> tags.

PHP - MySQL - Text Files - Speed
I've got a question that I'm sure is answered somewhere but I haven't run across it yet.

I've got a site with a lot of content that's being pulled from a database. Most of the content changes on a very regular basis.. I take it, push it into some templates, and render it to the screen.. pretty standard stuff..

But some of the pages have large blocks of static content. Just as an example, lets take about 50 lines of formatted static HTML.

This content doesn't change very often at all. The site is already designed to push through a template, so putting the content into static HTML pages isn't an option. The question is, should I store that content in MySQL or in a text file?

I figured that MySQL would be easier on the system. The fetches seem like they would be pretty easy for MySQL to handle, no complex queries. I figured that pulling from a text file would require apache/php to open the file, read the file and then close the file every time someone hit that page.

Am I putting unwarrented stress on our database?

Questions On Merging Two Text Files....
I will have a form field that will allow one of two text files to be uploaded to the db. This text file will have sections that are defined something liek this;

Opening All Text Files In A Folder
Im very new to php and need a bit of help. basically what I have is a folder with a number of text files inside. What i need to do is open every text file in that folder and then process the information inside each text file.

Im not really sure but I would assume I open the directory and place the name of each text file into an array and then loop through the array and process the contents of the text file.

#open directory

#foreach text file in the directory
#store file name into an array

#loop through array
#process code

Php Template For Multiple Text Files
I have over 800 text files. I need one php template webpage that can pull in text of requested file on request in url. Example:

http://www.gothinia.com/chronicle/epos.php3?title=Title_Of_Text_File_With_Story.txt

would place text of Title_Of_Text_File_With_Story.txt inside template called epos.php3
what code will do this in a simple effiencient manner?

Opening Text Files And Storing Them In A DB
I have a directory full of text files I need to open and store in the DB..... My question is about the file system stuff... I wanna open all files in a directory one by one is there a way to do a while loop of the files?

Includes And Writing To Text Files
i have 6 scripts, each writing to a text file.  in addition, i have an index file with links to all the text files that includes all of these scripts.  the problem is that the index file will run one script off the include list and then stop.  it's incredibly bizarre to me and i'm not sure why it's happening.

Reading Variables From Text Files
I am playing with several text files that have variables stored in two different ways. One text file stores the data like this:

hair=brown
eyes=green
gender=male

The other text file stores data like this: hair=brown&eyes=green&gender=male
How can I read the variables from the text file and use them in my php program? I know how to write them to a text file, but have no clue as how to read them.

Using PHP Offline To Manipulate Text Files
I need to create an application that will do fairly simple text manipulation
on 20,000 files in text format (html files). The files exist both on my
Windows machine and on a FreeBSD server. I prefer to do the manipulation on
my machine where it's easier to create backup copies, recover from
programming errors and so on, then upload the files to the server. All I'm
doing is extracting certain elements from each file and creating a different
file with the same content that will look better. I could do this in
FrontPage (or even Notepad) if I didn't have 20,000 files, so I need to
write an application that go through each file in a directory, open it,
locate the relevant text elements and create a new file that has these text
elements in an appropriate format.

I'm comfortable that I can write an application like this in PHP, even
though I do not have PHP installed on my computer, which is a Windows box
and is not being used as a server. Does this make sense? Can I install and
use PHP for this purpose without lots of server-related baggage?

Storing Classes In Text Files
is there a way to store class in a text file? and then recall thjem? and is there a better way to store variables and such than a text file, so its unreadable?

what i mean abou my question is.. is it possible to make two classes: User1 and User2, and then recall them so you can get User1.password and User2.password, User1.ID, User2.ID, etc.

Align Text And Searching Files
i would like to align my following code so that it sets it to the left side of the ;page. ive tried a few things but didnt work. also i would like to have it so that it only searches for picture and movie files. how would this be accomplished? Code:

Comma Separated Text Files
A client has requested that I make a php app which takes an uploaded image, reads the values and enters them into a database. I've made the upload script which works fine, and the script which enters the values into the database, the only thing left now is how do I make PHP read the file and extract the values? The file is a text file, each field comma separated.

Grabbing Text From Files/strings/etc
Wondering how to grab pieces of text from a file. Let's say I opened a webpage and want to have all the values of the input fields. This would be the contents of the file

<html>
<head>
...
</head>
<body>
...
<input type='hidden' name='hidden_w' value='123456' />
...
</body>
</html>

Now I want that value of the input field 'hidden_w' to be in the variable $w.
How do I this?

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.

Open, Search, And Process Other (text) Files
How could I use php to open, read, and perform operations on a file?

Say I wanted to open somefile.htm and search for instances of <p class="one">Foo</p>, strip the tags, then put 'Foo' in a variable called $foo... Is this doable?

Full Text Search In PDF And Word Files ?
I need to perform full text searches on a batch of PDF and Word files.
What is the best way to go?

After some research, I'm thinking of extracting the plain text from the
files with "pdftotext" and "catdoc", hamonizing the various possible
encodings to UTF-8, storing the text in a MySQL database, and then
using the full text search capabilities of MySQL.
Do you think that would work well? I am told that the files are mostly
text and won't be longer than 30 pages.

Problems W/PHPmyAdmin Inserting Text Files
I have been having some trouble with inserting text files into my MySQL database using PHPmyAdmin. I have used it before with success on other databases. Are there certain versions of MySQL that do don't support this. Whenever I try and submit the file it simply reloads the 'Insert Text File' form??

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....

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!

How To Change A Script Using Text Files To One Using MySQL?
I'm making a website for guitar effects and tabs, and I'm putting a system to let people rate an effect out of 5. I found this script in an online PHP library site, but I'd like to change it from using text files to using my database. I can either just add a field to each tab, "rating", or, if needs be, create an entire new table, "ratings", and link individual ratings to the tab in question with a tab_id field. Code:

Get Data From Two Files
I want to write such code :

// receive and save the variable as Engine ID
$EngineID = (int)$_POST['EngineType'];

dbconnect();

// In the file named dbo_J1708Vehicle, I want to get the list of
numbers in the column of iVehicleID

$sql = "SELECT iVehicleID FROM dbo_J1708Vehicle
WHERE iEngineTypeId = $EngineID";
$result = mysql_query($sql) or die();
$row = mysql_fetch_array($result)

// In drop-down box, I want to show the numbers in the file named
dbo_Vehicle, in the column of sDescriotion where iID= iVehicleID value
in prev result.

$sql2 = "SELECT * FROM dbo_Vehicle WHERE (iID) in ($row)";
$result2 = mysql_query($sql2) or die();

while( $row2 = mysql_fetch_array($result2) )
{
echo '<option
value="'.$row2['sDescription'].'">'.$row2['sDescription'].'</option>'
}

However, as you guess, it doesn't work. My another guess is.

$EngineID = (int)$_POST['EngineType'];
dbconnect();
$sql = "SELECT iVehicleID FROM dbo_J1708Vehicle
WHERE iEngineTypeId = $EngineID";
$result = mysql_query($sql) or die();
$row = mysql_fetch_array($result)

while( $row = mysql_fetch_array($result) )
{
$sql2 = "SELECT * FROM dbo_Vehicle
WHERE iID = .$row";
$result2 = mysql_query($sql2) or die();
$row2 = mysql_fetch_array($result2)
echo '<option
value="'.$row2['sDescription'].'">'.$row2['sDescription'].'</option>'
}

Scalability Of Perl Cgi Programs That Load Text Files
Suppose you have a perl program that is called by a web page to
generate another web page. The program is written to load data from a
text file on the server and make certain substitutions in the loaded
text prior to the output of html.

If one user is on the site, it should not be a problem. If many users
try to access it nearly simultaneously, will it be a problem?

example:

Dynamically Genetrate RAM (Real Media) Text Files
I am working on a record company's site.  They offer a selection of track snippets for stream/download. I would like to be able to dynamically generate the RAM (text File) to save manual input in the DB. 

Currently each RAM file has to be uploaded everytime a new track is added....but I'd like to have this created on the fly when a user is browsing the site.

user selects track...is forwarded to the dynamically generated RAM file...which in turn selects the appropriate media.

I can't think how i'd get this to work as I am trying to create a text file that is parsed rather than a peice of HTML that is read by a user.  Perhaps on the server I'd have to add PHP Parsing to the RAM mime type?

Get Data From Text File
I am trying to do is display the date like so: PHP Code:

Text Data Type
Can somone give me an example of using the text data type with PHP stored into MySQL.

Input SQL Data Through Text Box And Get Nothing?
I want to add SQL command through a textbox in the form using post
method,but when i execute the following file, nothing is added to the
database.
I can add
$sqlol = "update acc_account
set user_name='k'
where accountid=1";
to the database if it was added to the file but when i use $result =
mysql_query($sql); which execute the query, it get nothing. However,
the $sql statement do print out on the screen using print.

<?php
$conn=mysql_connect('localhost', 'shytr8');

if(!$conn)
{print "Error- Could not connect to MYSQL";
exit;}

$er=mysql_select_db("test");

if(!$er){
print "Error- Could not create er";
$query = "CREATE DATABASE test";
mysql_query($query);}

$sql=$_POST[SQLcommand];
$result = mysql_query($sql);
?>


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