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


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Store An Array In A Text Document


I want to store an array in a text document. what I've been doing so far looks like this:

fputs( $myFile, $myArray );

but all it does is write the word "Array", instead of the actual array. I'm new to php and I've done my best to search the manual and numerous web resources (including this forum) for an answer, so please don't flame.




View Complete Forum Thread with Replies

Related Forum Messages:
Fatal Error - Store Large XML Document To Mysql
I am trying to store large XML document to mysql. I think i missed around with Fopen setting which is the main cause of this problem. Can you look at the code and advise or suggest any soultions please. Your help will be extermly appreciated.

Source Code:
// initialize parser
$xml_parser = xml_parser_create();

// turn off whitespace processing
xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE, TRUE);
// turn on case folding
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, FALSE);

// set callback functions
xml_set_element_handler($xml_parser, "startElementHandler", "endElementHandler");
xml_set_character_data_handler($xml_parser, "characterDataHandler");

// open connection to database
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
mysql_select_db($db) or die ("Unable to select database!");

// read XML file
if (!($fp = fopen($xml_file, "r"))) .............

View Replies !
Writing To A Text Document
i would like to have user input saved as a txt file or html to the server instead of emailing the info to me anyone know of any good examples to follow or tutorials ect.

View Replies !
Formatting Text In Word Document
I am building a web site that displays the contents from a MySQL database in a word file and saves it to disk. Problem is that I can create the file but I dont know how to format the text in the word document.

View Replies !
Random Element From That Text Document
Coud someone please send me a script which uses a text document which pulls out a random element from that text document (like a picture or some text),

View Replies !
Insert Text, Ms Word Document
i've hit a wall regarding php and ms word. what i want is to open a
document containing bookmarks, insert text where the bookmarks are, and
save.

it's working, unless the bookmark is in the header part of the page (re
header/ footer). in that case i get an error saying the bookmark
wasn't found/ doesn't exist.

anyone got any tip on how to get into the header part of a word
document using php?

the following, simple code works when bookmark is in the main part of
document:

$empty = new VARIANT();
$word = new COM("word.application") or die ("some explanation");
$word->Documents->Open("C:PathDocument with bookmark.doc");
$word->Selection->GoTo(wdGoToBookmark, $empty, $empty, "bookmark");
$word->Selection->TypeText("text to be inserted");
$word->Documents[1]->SaveAs("C:Pathwith inserted text.doc");
$word->Quit();
$word = null;

View Replies !
Adding Numbers From A Text Document
I've tried, and searched and lost sleep over this one and I've nearly admitted defeat. I have a text document with certain details listed which comes from another document which comes from a series of forms. The document, let's say 'test.txt', has numerical values at lines 5, 11,17, 23 and so on so forth (just add 6 to the last number and you get the next).

Each month the numbers in the file will be added together to give a total. Now there could be only a few numerical entries into the file, or there could be a hundred entries. How can I add the numbers from test.txt lines 5, 11, 17, 23, 29 etc etc together to make a total without having to do the "$lines[5], 1, 4 " + $lines[11], 1, 4" etc etc.

View Replies !
Converting Text For Word Document
I have a few people who post content in a CMS. They write their stuff in Word, then cut and paste directly into the form. When this happens, it has characters in it (such as smart quotes, ellipses, etc) that cause the HTML validator to throw errors. I know it's a bit anal, but I'd like to be able to strip/replace these characters upon posting the text.

I've written a rudimentary function that does a bit of the leg work with the basic haracters, but I would like one that will just convert any non-ASCII character into into it's ASCII counterpart. I've looked a bit on Google but haven't found anything. know of a solution out there already, or know of any resources on common nasty characters from Rich Text/Word Documents and their ASCII counterparts?

View Replies !
Write A Function That Will Read In A Text Document
I'm trying to write a function that will read in a text document containing various bespoke tags which I then expand into the appropriate HTML. I've done most of them but was wondering if someone could help me with this particular one .. I'm guessing I should be using preg_replace but can't seem to get it to work.

I have a variable called $rec_id which is an integer. The following is the conversion I want to perform: Code:

View Replies !
Loading A Word Document Into A Text Area
Is it possible to do the following with php?

1. display a form which includes a <textarea>
2. press a button on the form that would display a directory dialog box which would allow the user to navigate their local directories and select a word document
3. the contents of the selected word document would be sucked into the text area which - on submit - would then be inserted into a database on the web server.

I've looked at the fopen() function, but that won't open up a directory dialog. I've also read elsewhere that the file chosen needs to be uploaded to the server before it can be displayed in the textarea.

View Replies !
Copying Username And Password Form Info To Text Document
I want to log a username and password before the password is md5'd. This is the code where you login to the forum. What should i change the code to so that when someone logs in it copys the info they type as their password and username to a .txt or html file on the server so that I can go to that file and see their password and not have to spend like a week cracking it.

if ( $_POST['UserName'] == "" )
&nbsp; &nbsp; {
&nbsp; &nbsp; $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_username' ) );
&nbsp; &nbsp; }
&nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;if ( $_POST['PassWord'] == "" )
&nbsp; &nbsp; &nbsp;{
&nbsp; &nbsp; $this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'pass_blank' ) );
&nbsp; &nbsp; }&nbsp; &nbsp;
I know this is kind of dodgy but help would be appreciated =) Please bare in mind I have no php or sql knowledge whatsoever.

View Replies !
Read Text File And Store In DB
Is it possible to upload a text file, read the contents and extract certain strings, words, phrases, etc. from it and store it in a mySQL database for later searching via the web? If so, are there any scripts/modules out there that accomplishes this?

View Replies !
Include() - Store The Text In The Index Page
I have a index.php page that has some text on it and I also have a edit_index page. From edit_index you can edit the text on the index page. But I don't want to store the information in a database or a text file but instead want to store the text in the index page.

Since the index page is PHP i made a variable at the top named $index_content and that holds the current text. What I want to have happen is for me to be able to, from edit_index, is edit the variable with the new text. So when I hit submit on edit_index I want it to call up index.php and redefine the $index_content variabled stored in the page. But i don't know how to write to a page like that when it's not apart of the script being executed.

I tried require(), but that didn't work, and I tried include() but that didn't work either. Is there some way to do this that i'm not aware of?

View Replies !
Store And Display Information In A Text File
I want to make a script that records the users that visited main.php into a file called visitors.txt and displays it on a page called views.php. Here's an example. Let's say the link is 'http://perks.mypimpedlayout.com/profile/main.php?screenname=persons_sn'. I want to store 'persons_sn' in visitors.txt and display the users on views.php. Help would be appreciated.

View Replies !
Trying To Store And Retrieve Formatted Text From MYSQL
I am trying to store formatted text (windows format) into a MySQL
database and then retrieve it. The field in the database is a
varchar.

I cut and paste the test into a form field formatted, then
call the PHP program to add the record using POST. When I get the
text out, it has lost it's formatting. Formatting in the text is
achieved by multiple spaces not tabs, but even multiple spaces are
converted to a single space and the carrage return/line feeds are
lost. Below is the basic code I am calling when I click POST in the
form. Code:

View Replies !
Multi-lingual Site - Where To Store Large Amount Of Text?
Whats the best way to do a multi-lingual site in PHP?

The site needs to be in 2 languages. Ive done all the ground work, and it all works beutifuly. Alt tags, buttons / navigation all in a language file which is included at the top of each page but now ive started entering content this file is getting extremely BIG.

There will be 100 pages each language.... ive entered the text for 23-4 pages and file size is already 30k ----- was 3k before entering content. So add the rest of the pages, and this file will become massive.

Now, will this affect the loading time of the site (say language file is 200 - 300k?) .... if so would it be better using MySQL??

The reason im not using MySQL is because im not sure how to enter content into it.....

i.e. how many fields should you create? because some pages have images splitting text, others have tables in between etc.

View Replies !
Store Values In An Array
$a=10;
$a=15;

while ($a <= $b)
{
$a++;
}

The output is 10,11,12,13,14,15

How to store the values of $a(10,11,12,13,14,15) in an sigle array.

View Replies !
Store Classes In An Array?
Is it possible to store classes in an array? I am fairly new to PHP,
and haven't found anything either way yet.
I have a program that where you can have multiple notes attached to a
ticket, which are stored in a database. I would like to just pull all
the notes from the database, storing each one in a seperate class,
which itself is stored in an array (well, another class, but it's a
classList, it's mainly an array).
I'm getting an error when I run the page:
"Cannot use a scalar value as an array", and "Call to a member function
on a non-object". The second is related to the first, as I'm calling a
function on the array value.
If it is possible, I probably coded something wrong. If that's the
case, I'll post some code.

View Replies !
Get Data From The Db And Store It In An Array
I want to have an input field in my Admin CP when you are creating a Forum where you can input a list of numbers (member ids) seperated by commars, like this:

Quote1,6,4,8,2
These will be the ids of people who can moderate the Forum and will be stored in the db along with all the other stuff like forum name/description etc.

That's easy enough.

Now my problem is I need to get that from the db and store it in an array... basically so I can do something like:

<?php
if(in_array($_SESSION['mem_id'], $forum_moderator_array)) {
    echo('Congratulations, you are a forum moderator.');
}
?>

How can I go about doing this?

View Replies !
Store A Array As A Variable
is there any way that i can store a array as a variable because i dont want to creat a database for thousands of variables. heres what i thought of so far

<?PHP
$arrayval = "1,3,2,7,4,6,8,15,12,78,96,1203,1029,39509,12999";
$array = array($arrayval);
echo $array[1],$array[3],$array[2],$array[5],$array[6],$array[4],$array[7],$array[9],$array[5],$array[10],$array[13];
echo "<hr>";
echo $arrayval;
echo "<hr>";
$sum = $array[1]+$array[3]+$array[2]+$array[5]+$array[6]+$array[4]+$array[7]+$array[9]+$array[5]+$array[10]+$array[13];
echo $sum;
?>

View Replies !
Store Array In Session
i store my shopping carts items in an array in a session like this Code:

View Replies !
What's The Best Way To Store An Array In The Database
I am trying to build a simple tree menu where the main items can be either a link or open up a subList of items which themselves can belinks or open into more submenus and so on.
An example is:

$ar = array(
'new_user' => 'newuser.php',
'tst1' => array(
'subtst' => 'subtstlink.php',
'subtst2' => 'sublink2.php'
),
'heyhey' => 'heyhey.php',
);

I am wondering what is the best way to store that in a mysql database (Both the item name and the link to it). Is there any php function that will allow me to make such an array into some sort of variable (String?) which can then be read easilly and made back into the array for manipulation and creation of the tree menu?

View Replies !
How To Store Array In Cookies?
I try to store array in cookie this way:

for($i=0;$i<5;$i++)
{
    $field[]='test'.$i;
}
$_COOKIE['field2']=$field;

Is it possible do it that way? I don't want to store each value of array list store separately. I'd like to store them at once. If I was storing values just to another "normal" variable (not cookie), I would do it this way: Code:

View Replies !
How Do You Store An Sql Result In A Php Array?
How do you store an sql result in a php array? The array will hold, the following fields; itemid, itemname and itemdesc. I would then require, depending on the user selection to query the array by itmeid, and return the itemname.

View Replies !
Can I Store An Array In MySQL?
I would like to store an array in a MySQL table. The values will be numeric and ranging from 1-999. I'm not sure if this is possible, and if it is then I'm not sure on the correct field type to use.

View Replies !
Store Variable In An Array
so i have a query that returns a bunch of rows.... i display the contents of the query into a table... one of the variables that the query returns is $title....

after each row is returned im wanting to store the $title variable into an array, so i can then access that array later... here is my code for storing $title into the array Code:

View Replies !
Store Mysql Results Into An Array
i just started using php. i've used it before as a maintainer. fun stuff. well now i'm the writer. i want to abstract all the DB commands away from myself and all other developers. so i'm writing a function to query the php database from all users of the database and store them into an array as a return value so that i can seperate my database code from my html creation code.

1. is there a way to put all my database functions into a php file and include that file into all my other php pages? similiarly to a #include in C++ or a import package name in Java?

2. my code to run down the fetched results and store them into an array doesn't seem to be working the way i want it to. if i print out the results from the mysql returned fetch the data is fine. however the array seems to print out "Array[elementnumber]" instead of the value. Code:

View Replies !
How To Store Checkbox Values To An Array?
I need to allow the user to select multiple mysql records via an html form checkbox.  On submission of the form I would like to store these values in an array for either multiple record deletion or creating a list of records. Code:

View Replies !
Four Fields That Are Dates, Store As An Array
I have a form that has over 100 fields. I have four fields that are dates that I would like to store as an array. When I submit the form I place the dates in the array like so:

$planworkdate = array("mon" => $planworkdate0,"tue" =>$planworkdate1,"wed" =>$planworkdate2,"thu" =>$planworkdate3);

and insert into mysql database. When I try to retrieve the data I get the word Array for the result. What am I doing wrong?

$query = "SELECT planworkdate from general";
$resultall = mysql_query($query);
$planworkdate=mysql_result($resultall,$x,"planworkdate");

print $planworkdate; ...

View Replies !
Take All The Results From A Query And Store Them In An Array
trying to get my head around arrays, and I want to take all the results from a query and store them in an array so that I can use them  for later use: Code:

View Replies !
Store Form Fields To An Array
i have a form which consists of several fields for name, address, number etc. i use a php form to process this and output it onto a html form. the thing is, i'd like to store the information in an array. so for each user, the array will have their details. and this can be printed on the screen. can you tell me how this is possible. i have seen examples of arrays, but the values are assigned to the variables already.

View Replies !
Store The Entire Table In A Two Dimensional Array
I am reading info from a tab-delimited text file and I was wondering if anyone knew how to get this concept to work. I am trying to store the entire table in a two dimensional array, but the way I'm doing it right now won't work.

for($i=0; $i<$numrows; $i++)
{$columnsvalue[i] = explode(" ",$newfile[i]);}

does anyone else know how to better work with multi-dimensional arrays?

View Replies !
Mysql_fetch_array Way To Pull Out All The Data, Store It In An Array
I have a webpage which runs repetitive queries agaist a database in order to extract one item at a time and then put the items in an HTML table. The reason for this is formatting, plus the page hits 4 databases.

Instead of running multiple queries pulling one item at a time...is there a way to pull out all the data, store it in an array, and then pull individual items from the array with php as I want to insert them in the table? So, example is Code:

View Replies !
Variables To Store (Name,Species,Sex) Inside An Array
In PHP, is there anyway of using variables to store each piece of information (Name,Species,Sex) inside an array. Then, when it comes to fetching the information, the array position (e.g. 0) is called along with the information type (Name etc). A bit like the following: record(1).name The information is coming from the record array, at position 1 displaying names.

View Replies !
Store While Statment Data In Array Using Session And Retrieve?
I wish to store retreve value from my sql using session array and retrieve this value.
here is my while statement, which is displaying records from my database. I want to store all this value in an array using session and than retrieve this value on click of the table row. Code:

View Replies !
Array Problem - Extract And Store In Seprate Variables .
I have an array from a program of the type $list_box_contents[$row][$col]['text'];
 There are 3 columns  and an indefinite no. of rows.

Each array element contains a few bits of information. I want to to extract this and store in seprate variables .

$list_box_contents[$row][2]['text']; has 2 bits of information, a price and a small text box with some text. How can extract the price data from this .

View Replies !
Store The Selected Checkbox Values In A Variable Or An Array?
how to store the selected checkbox values in a variable or an array?

View Replies !
Array Problem... - Store This List In $_SESSION['liste'];
the user selects 6 numbers in a list I have to store this list in $_SESSION['liste']; (I cant do it differently) the list is stored like that: 34-21-44-32-12-11 (cant do it differently either)

what I need to do is to explode the array, get rid of the - , sort the values in ascending order and send them to my table as a string. so in the end I should have: 111221323444

I tried using a variation of laserlight's script (given in a previous post) without success... hope that someone will have time to give me a hand again in telling me what I could change in saberlights script to make it work.

View Replies !
Explode - Open File Store The Numbers In An Array
I have a .txt file looking like this

3
4
56
23
59
10

i want PHP to open that file and store the numbers in an array something like this

$q = "3,4,56,59,10"

Now i want to read $q and see if it contains 56 and 10 (it does) Code:

View Replies !
Document.write(document.referrer)
Anyone know how I can use this java statement:
<Script Language="JavaScript"> document.write(document.referrer)</SCRIPT>

in the following php email message? PHP Code:

View Replies !
An Array Of Text Boxes
I have the full code in a php script where I essentially display a form with checkboxes, and 2 text boxes associated with each checkbox to record grades ( marks and remarks ). The form displays correctly and the checkboxes I select do pass the correct id numbers for the students to be graded, also the numeric data in the first textbox is correctly transmitted HOWEVER the data in the second textbox gets randomly truncated.

e.g, if the "remarks" textbox has 'hello', it gets truncated to 'o'. It seems I'm not resetting something or there is another simple oversight somewhere, perhaps the script treating the data as a string rather than as an array Code:

View Replies !
Use An Image Instead Of Text In An Array?
I was wondering if it was possible to use an image instead of text in an array? Here's a condensed version of what I'm using: PHP Code:

View Replies !
Matching Text In An Array
I know this is a really easy one, but its been a long day and the old brain has packed up.

I've got an array with the main keys for a number of IP addresses, as follows:

$IP = array();
$IP[] = "216.239.46.";
$IP[] = "216.239.3";
$IP[] = "216.200.130.";
$IP[] = "216.35.116";
$IP[] = "216.35.112.";
$IP[] = "216.34.121.";

Now, the string $ip_address contains the full IP address of someone visiting the site. I want to compare it with the list above and tell if it is a crawler.

What code should I use from here? I've tried various things, but found nothing that works reliably. I know I'm missing something obvious and hope somebody will put me straight.

View Replies !
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...

View Replies !
I Need To Addslashes() To The Text Box Array
I need to addslashes() to the text box array that is posted on my page but not sure where is should go within my code. I have the following code:

if (isset($_POST['textarea']) && is_array($_POST['textarea'])) {

        foreach ($_POST['textarea'] as $textid => $textarea) {
            $q= "update mytable set textfield= '$textarea'";
            $r= mysql_query($q);
        }
}

If someone could amend the code or highlight where I need to apply addslashes() i would be grateful.

View Replies !
Using Array To Replace Text
I'm currently using this code to search an array for a word and if found replace that word with ****. Now, can I use an array to specify both the bad word AND a word to replace it with? My current code:

function find_replace_happy ($word){

$badwords = array(

0 => 'badword',
1 => 'badword',
2 => 'badword',
3 => 'badword',
4 => 'badword',
5 => 'badword',
6 => 'badword',
7 => 'badword'

);


$word = str_replace($badwords,'****', $word);
return $word;
}

View Replies !
Open A Text File And Put Into Array
I want to open the text file and put it into an array so i can search the contents of the text file.I've figured out how to search an array but cant seem to open a file into an array and then search it. I want to take blah.txt open it insert it into $some array
and then use the array_search function to search for the word the user puts into a form.If you can point me to a tutorial, that would be helpfull.This whole search thing is driving me nuts.Opening and writing to files is easy...now searching the files im writing to ??I'm lost.

View Replies !
Create A Delimited Text Array
How can I create a delimited text file to work with this script. I would like to put this first part in a text file and load it into an array so the php script can parse it. Code:

View Replies !
Access An Array From A Text File?
Im trying to build an array from elements I have stored in a text file
(So I can access them on multiple pages). What is the syntax for this?
I thought it might be...

storedArray1 = array(require_once("/arrays/stored_array_1.txt"));

or

storedArray1 = array(include("/arrays/stored_array_1.txt"));

but I guess you can only use the 'include' statement when inserting
text into html code NOT php code?

View Replies !
Multidimensional Array From Text File
Im having a problem reading CSV data from a text file and storing it in a multidimensional array. I have a text file like so.

Cathal|kyle@example.com|83.103.100.300|Wednesday 29th August 2007 @ 17:27-13|66023f4984
tony|tonto@example.com|83.107.82.300|Friday 31st August 2007 @ 12:46-49|1c3fd4594d
steve|imapisces@example.com|86.5.147.300|Friday 31st August 2007 @ 17:22-19|d61f895714

I want to take this data and create a multidimensional array from it. I have been up all night trying various ways like the one shown below but I cant seem to achive what I need it to do.

$fp1 = fopen ("admin/data/pred.txt", 'rb');
while ( $array = fgetcsv ($fp1, 1024, "|")) {$multi_array[$array[0]] = array ("$array[0]" => $array);

View Replies !
Can't Load Text File Into Array
I have adapted this function to filter profanity from a guestbook. Somehow the text file does not fill the array. Each entry in the file ends with a newline.

If I define the array in the function, the function works fine, replacing the offensive words with *s. Can someone tell me what I might have done wrong with either the file or the function? Code:

View Replies !
Indented Text List To Array
I'm trying to get a tabbed list into a structured array and can't seem to get it. I'd like the get from this: PHP Code:

<?php
$contents = array(
    'Level 1 Item 1',
    'Level 1 Item 2',
    " ".'Level 1 Item 2 > Level 2 Item 1',
    " ".'Level 1 Item 2 > Level 2 Item 2',
    'Level 1 Item 3',
    'Level 1 Item 4',
    " ".'Level 1 Item 4 > Level 2 Item 1',
    " ".'Level 1 Item 4 > Level 2 Item 1 > Level 3 Item 1',
    " ".'Level 1 Item 4 > Level 2 Item 1 > Level 3 Item 2',
    " ".'Level 1 Item 4 > Level 2 Item 1 > Level 3 Item 1 > Level 4 Item 1',
    " ".'Level 1 Item 4 > Level 2 Item 1 > Level 3 Item 1 > Level 4 Item 2',
    'Level 1 Item 5',.

View Replies !
Returning Text Input Type As Array
I'd like to make all the text inputs in this form to be part of an array. The reasoning is that the form is built dynamically so there are times when there are 4 inputs while other times it's 12. When the form is submitted I need those inputs to be error checked and such.

View Replies !

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