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




Get Date From Text/php-file


I got it going.
Now i have another question;

Is there a way to link a date to a persons name,
so i can get the pop-up, and the pop-up
then automatically grabs the right name, and displays it?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Get Date From Text/php-file
I'm new to PHP, and i want to create a pop-up (on page load) on certain dates..
What i have is the script for the pop-up:

<body scroll="auto" <?php $today =date("d-F"); if ($today==$datum)
{echo "onLoad=".$g_birthday_pop;}?>>

The pop-script =
$g_birthday_pop = <<<EOT
"MM_openBrWindow('http://www.nu.nl','popup','width=300,height=300')"
EOT;

$datum is in another file (include/datum.php):
<?php
$datum= "30-December";
?>

And this works if the date is 30th of December,
but i want it too on other dates that you put in $datum
Something like:
<?php
$datum= "30-December";"10-March";
?>
So i want to control the pop-up just by editing the "datum.php"-file

Read And Display Japanese Text From Text File
I posted a question regarding reading japanese
text from a text file.

Well, since I solved the problem, I thought I'd post my solution for
the benefit of other people with the same problem.

The plan was to make a script to read and display japanese text. I
will use it for making a japanese proverb script and for a japanese
language study script.

Method :

I wrote a simple kanji text file (saved with UTF-8 encoding)
I wrote a simple PHP script to display the file contents (saved with
UTF-8
encoding)
I specified the content-type header for the HTML page :
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

*** All files have the same encoding. ***

UTF-8 supports japanese characters.

and it works!

this is my PHP (and HTML) script :

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PHP : Japanese Text File Read : Exercise 1</title>
</head>
<body>

<?php

$filename="japanese.txt";
//open file
$fp = fopen($filename,'r');

//loop through each line in the file
while($line=fgets($fp))
{
//output current text file line
print $line."<br>";
}
//close file handle
fclose($fp);

?>

</body>
</html>

I know it's a very simple script, for testing purposes only. It
displays the contents of the japanese text file line by line.

The key was to save all files in the same encoding (I used UTF-8) and
to specify the encoding / charset in the HTML header (<meta
http-equiv="Content-Type" content="text/html; charset=utf-8">)

Remove Text Header In Text File
I have been having trouble removeing two header lines at the top of my txt file. You will see in my code the different things I have tried but with no luck. Below I posted my script and data. I am doing a few other things in my script as you will notice but this is the only thing I am having troble with. Code:

Text Field As Date (MySQL)
I have a generic table used for many different generic
functions. the fields are mainly varchar's but one of these varchars
contains dates (in the format dd/mm/yyyy) for one reason or another.

My question is, can I perform a query on this table, using date
functions on this varchar field? I.e. search for the latest date?

Text To Date And Insert To Mysql...
Kindly break out the 4x2 and bring me to my senses.
I seem to have gotten myself totally confused with php.net, mysql.org pages
on dates etc, as well as groups.google.

Could someone explain, even using pseudo code, how to take a text input I
have set up as YYYY-MM-DD using php, and convert to a value mysql will
insert into a Date (not timestamp, not datetime) field.

Mktime Returning Wrong Text Date
I am pulling numerical month data from the DB and converting it to a text format using mktime() and date() functions. PHP Code:

Text Input Of Date And Timestamp Fields
I'm working on a PHP frontend for a PostgreSQL db and I'm looking for the
best way to create date or timestamp inputs. Let's take a date in the
format yyyy-mm-dd as an example. This is too error prone, I know my users
will do it wrong

<input type="text" name="fieldname">

Right now I'm thinking about something like this:

<input type="text" size="4" name="y_fieldname">-
<input type="text" size="2" name="m_fieldname">-
<input type="text" size="2" name="d_fieldname">

but this is IMO a very ugly solution, because after the SUBMIT I have to
glue all the parts together before inserting the values into the db.
Something like this:

<input type="text" format="yyyy-mm-dd" name="fieldname">

Date Sorting From File
I am doing a flatfile calendar, and I need a way to display all activities for a whole year.
Each month has its own file, with the following layout

2003-09-01 Da message 0 // date message priotiry
2003-09-02 Das besked 1

My problem is that I need to somehow get this information and print it out in an order of date. The information is not saved in any order so I need to sort it in my code, My plan was to go through all the files (plain text), and collect the left side in one array and then sort it, then pair the right side with the correct date. Problem is, I don't know how to do that.

How To Display The Date Of A Php-file?
I'd like to display the actual date of a php-file (like: last changed at ...) ... how could i do this?=

File Last-modifed-date?
Is there a way the retrieve the last modified date of a certain file with PHP?

Text Box To .txt File
does anyone know how to make a text box in php that when submitted, it writes to a .txt file?

Add Something To A Text File?
How would I go about adding a string on a new line at the end of a text file?

Finding Date File Created
What function will return the time a file was created? I see
filemtime(...) returns the time that file was last Modified and
fileatime(...) returns the time that a file was last accessed but what
about created?

Displaying Modified Date Of A URL File
I want to display a web page with links to various documents and display the date each document was last modified next to the link. I've found the filemtime command and that works quite nicely for "local" files. However, filemtime doesn't work if the file(s) are refered to by their URLs (which is how I need to do it).

A comment on the manual page (http://www.php.net/manual/function.filemtime.php3) refers to having to use "Socket Operations" but the link posted with that comment doesn't work (it just goes to a page saying the website has been rearranged).

Need PHP To Read File Date In Directory
Is there a way to use PHP to read the date of a file that is uploaded
into a directory and then print out that date on another page?

I'm looking to have a specific file (/texts/filename.pdf) located in the
directory and the date of its last change/modification printed into a
date("F, n, Y"); format on another page. I checked the PHP manual but
couldn't find any date/time functions that were what I needed.

Modified Date For Alternative File
Is there a way to add the last modified date for an alternative file into another one? My problem is that when I use getlastmod it is looking at the date on a file that controls headers/background etc for the page, but not the file that is accessed during modification of the data. Is there any way to add a line of code to get the modified date from the data file?

Date From Form To File, Mail
I am trying to get a date stamp on the results from an HTML form. Through PHP3, my form writes a file or emails the results without the date and I would like to get the date in there. It is really simple, but I don't know how to do it.

Date And Filetime Of A HTTP-File
I want to transfer a file from a http-server to another.
Well, that goes fine like this:

$upload = ftp_put($conn_id, "$destination_file", "$source_file",
FTP_BINARY);

But I want - before the transfer - to know wether the $source_file exists.
More, I want to know and keep its original filetime.

I tried with file_exists. Don't work. So don't work fileatime etc. either.



Text File Display
I have a number of SQL reports that create standard 132 column text files. The user wishes to view these files in a browser in addition to their daily printing on a laser printer.

I can handle directory structure, etc with PHP but I would like to know what is the best way of displaying these text files on screen. We can select them but they are very plain. Is there a TXT2HTML ot TXT2XML type tool that can display headings, bolding, etc without too much difficulty. I would rather not reprogram the reports as there are hundreds of them, and embedding HTML would not be an answer as they need to be printed on a regular laser.

Saving To A Text File.
I haven't been able to find a way to save the results of a MYsql query into a tab delimited text file... Anyone know how to do this, or if there are any already written scripts out there that perform this, or a similar function?

Database Row To Text File
I need to get the contents of a MySQL database field into a text file, and write the file to the server. I can not seem to get any filesystem functions to work, because it tells me I do not have permission to do anything. I am on virtual hosting, so it seems easier for me to try to FTP files to my own server.

Perhaps you guys can give me some pointers, this is kind of the idea I am running on:

Writing To A Text File
i have a text file with the number 250 in it and nothing else. i have a variable which is worth a 300. How can i add this value to the one in the file so that the value of the file has changed to 550?

Get The Last Word From A Text File
i have a text file that's update all the time. i need to get the last word from it. how can i do that?

Write To A Text File Once Only
I've got a script that writes to a text file:

Text File Into Variable
I'm setting up an script that will send mail to an address given by a user. The problem is that the body of the e-mail varies depending on a few responses that the person gives, and writing out like 1000 lines of code just to get each of the outcomes covered is not my idea of fun. My question is, is there any way to make a variable in PHP the contents of a .txt file so I don't have to have that big of a script?

Retrieval From A Text File
How would I go about retrieving info from a text file into a variable field? If the data is stored in more than one line or separated by line breaks?

Php File Showing As Text
I have tried to upload a tested PHP file to my server and every time it gets
accessed it displays itself as text and does nothing that its supposed
to...

Form To Text File
I don't know anything about PHP, ASP, CGI, all I can do is use Microsoft FrontPage to edit html. But I have been searching the internet for a script (any laguage) that can send an html form to a text file. But I need the new data to replace existing data in the text file every time I submit new information.

Is this possible in PHP or any other language? I’m hosted on a UNIX server with php installed and I have access to my cgi-bin and all I need is this little script to complete my website.

Str_replace From Text File
I want to use a text file with words that needs to be replace. $theentry = str_replace(array('word1', 'word2'), '*****', $theentry); Instead of array('word1'),'word2') i want textfile.txt to be opened with all the words to be replace with ******.

Text File Instead Of Database?
Does anyone know a script that I can use to manage members of my website (preferably with a control panel-type interface) but without using a database? I read on hotscripts.com of one that uses text files instead, but the link says that the site is no longer offering that file.

If someone could help me it would be great, as I know nothing about scripting. By control panel, I mean a page that I can go to on my site (not open to the public) that I can use to Admin the users. I would like it to go something like this: (this is what was offered at hotscripts.com)

New Members Username:
New Members Password:
New Members Name:
New Members E-Mail Address:

And optionally (I don't really need it, but if its possible, hey why not) a place for me to put in an admin username and pass to get into the page mentioned above. I would also like to be able to implement this script on my main page (see here for what I mean.

Exploding Text File....
I want to put a text file into a form field, and then submit it to a page that will split up the text file on two criteria and then loop through each split result inserting new db records. A sample text file would be:

question 1;option1;option2l;option3

question 2;option1;option2l;option3

question 3;option1;option2l;option3

I need to split it on blank lines and then again on the options so that my insert would be insert questionname, option1, option 2....into questions. Can someone help please. I know I can use explode, but unless I am missing something then its just not working for me.

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

Deleteing From A Text File?
Is there a function that deletes a line from a text file?

Exporting From Db To Text File
I have the following sql statement that works from phpmyadmin and from the MySQL command line, but not php. The resultant $sql variable is the following:

$sql=select logrecno, county, sumlev
into outfile "/tmp/census.txt"
fields terminated by ','
lines terminated by ""
from sf1_msageo
where sf1_msageo.county=97 and sf1_msageo.sumlev=140

$result=mysql_query($sql); The query executes, returns no messages, and does not create a file. Any idea as to what I'm doing wrong?

Comparing A Text File
I was wondering if this is possible: Compare a row from a table to a row from a text file, and if that row is not in that text file, then delete it from that table, and move it to another one. Say for example I read in a text file and assign the following variables: PHP Code:

Search A Text File
I have a text file that each line is an array, I think. I looks like this

name | id | # | # | # | total
name | id | # | # | # | total

and so on...

I would like to seach the file by "id" and only display the line with the particular "id".
I also think that the bit size of each line will change from line to line, so I don't think that I can put in a static number to search to the end of. I thought about using fseek(), is that the best way to go.

Php Generate Text File
I have been trying for the past 3-4 days now to get flash to write into a text file for me. Basically I made a rating script on flash and then I made another php file that counted the top 10. I want to get the info from the top 10 to a text file but I've been stuck for a while now.

I read php.net for the commands, kessler's tutorial, but I'm just missing something. I posted the top 10 script that works and the other that doesn't work when I try to text can someone please tell me what I'm messing up on? PHP Code:

Text File Behavior
I have a question about the behavior of a text file thats being written and
read to.

Say Im using an XML file as the database for my little application. Users
come to my site and the file is read and parsed and coverted to some display
in html. On another page users can add information that updates this XML
file.

Is there any risk in this approach? While the XML file is being written to,
what is its readabililty? And vise-versa. Assuming Im using the standard
read write functions for files in PHP, will the read wait for a write to
finish, etc.

Edit Text In A Txt File
here is the php code!

i am trying to use to 'edit' hyperlink to edit txt in member.txt.
Problem is that it reads the values ok into an array, however when i
attempt and update new values into the file, i get no results. Does
anybody know where i am going wrong????

<? session_start();
// Set updated content for user

if(!isset($_POST[Submit]))
{
// read content from file and place into array, this is used to put
initial content into form
$fc=file("../username/member.txt");
$userid_no = $_GET['record_id'];
$line = split("|",$fc[$userid_no]);
$user_id = $line[0];
$password = $line[1];
$firstname = $line[2];
$lastname = $line[3];
$email = $line[4];

}
else
{
if(isset($_GET['record_id']))
{
// build record into string from post values
$update = $_POST['user_id'];
$update .= "|";
$update .= $_POST['password'];
$update .= "|";
$update .= $_POST['lastname'];
$update .= "|";
$update .= $_POST['firstname'];
$update .= "|";
$update .= $_POST['email'];
$update .= "|";
$update .= "";
$update .= "|";
$update .= "2";

Write To Text File
I have a form which takes user input. On submit, the form will run a
php script that will create a new text file using the user input.

I want this text file to popup or open in a new page. The problem is
that when the page opens it still shows the old text file, i need to
hit refresh for it to show the last user input.

the html file (greatly simplified):
<html><head>
<title>Untitled</title>
</head>
<body>
<form action="action.php" method="post">
<p>Title: <input type="text" name="Title" /></p>
<p><input type="submit" /></p>
</form>
</body>
</html>

The php file (simplified as well):
<?php

$spot_code = $_POST['Title'];

// Open the file and erase the contents if any
$fp = fopen("myfile.3dml", "w");

fwrite($fp, "<TITLE NAME=" . '"'. $spot_code .'"'. " />
");

fclose($fp);

//redirect
header( 'Location: http://localhost/mytest/myfile.html' );

?>

the text file, myfile.3dml is embedded in myfile.html (it requires a
plugin to view - it's a 3D world). When myfile.html is opened it
displays myfile.3dml but it needs to be refreshed to show the current
input.

Searching A Text File
I want to be able to search for text in a text file. For example if there was this in a text file:

php1:mysql1
php2:mysql2
php3:mysql3
php4:mysql4
apple:orange
php5:mysql5
php6:mysql6
php7:mysql7
php8:mysql8
php9:mysql9

I want to be able to search for the word "apple" and then echo what is next to it, which would be "orange". How would I go about doing this? Also, if I were to search through these files in php daily with a lot of people searching through them, would my text files become corrupt?

Parsing Text File
I'm working with a text file that contains the names of websites and their corresponding URLs in the following fashion: <a href="www.cnn.com">CNN News</a>
Each site and title is separated by line breaks. I'm not very experienced with fopen, fread, etc. and was wondering if anyone could give me pointers on how to go about reading the text file line by line and saving the URL and title in separate columns in a database.

Oh, and one more thing. The categories of these sites are also included every so often. I was hoping to save the category in a third field. Ex:

News ( new line here)
<a href="www.cnn.com">CNN News</a> ()
<a href="www.bbc.com">BBC News </a> etc.

Trying To Modify A Text File.
What I need to do is to look at each line in the text file, find the userid that an administrator inputs into a form, and delete that line so that a new line can be appended with updated info.  Or, if anyone knows of an easier way to modify info on a certain line in a text file, I'm all ears.

Write To Text File
function Save_Data($word) {
$fp = fopen("search_strings.txt", "w");
fwrite($fp, $word);
fclose($fp);
}

I'm trying to keep a list of keywords. Everytime i open the file to check it, it only has 1 word in it. it keeps overwriting the previous word. How do i kee a proper list of words?

Edit Text File
I am trying to find a specific line, which starts with a unique word, then delete that line in the .txt file then rewrite that line. Code:

New Line In Text File
I'm trying to create a text file in php to generate a playlist. The problem is that I cannot manage to create a new line in the text file. Using /n still places text in the same line and just inserts a symbol to indicate the 'new line'. Using

just works when viewing the document in HTML (which is not what i need in this case). But what I want is to physically insert a new line in the text file so that when i open the generated file using notepad i see that there are actually new lines in the document and so that the playlist can be read normally with a music player.

Updating A Text File
I am currently building a PHP app, and some of the configuration is stored in a 'config.php' file which is created during the install. After install I would like for the users to update these values separately. for example:

line 5 of config.php is:
$language = 'english';

and this may need updating from the admin screen (using results from a drop down list of languages), without touching the rest of the file. Is there any way to locate and update a single line of the config file in my php script?

Putting Text Into A File
This code is supposed to create a file and insert some text into it. I had it working, but the file was not being put in the right place, so when I went to change it, this is what I got, and it doesn't put it there. Code:

Delete File (timestamp & Date Problem)
I want to delete a file which is modified at least 60 minutes ago. i failed to do it.i fetched the last modified timestamp using filectime() or filemtime. but how can compare if it is last modified at 60 mins ago?


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