473,240 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,240 software developers and data experts.

Copy data between files

Ken
How do I copy data from one file to another? from $_SESSION['fname'] to
"fname"

datafile.php has

fname: $_SESSION['fname'];
lname: $_SESSION['lname'];

I would like to automatically copy the data to

second.js

var fname = "fname";
var lname = "lname";

to be used in JavaScript.

I am familiar with
$contents = file_get_contents($filename);

and I know how to copy files but not data inside of the file.

Thanks for the help.

Ken


Jul 17 '05 #1
3 1996
Ken wrote:
How do I copy data from one file to another? from $_SESSION['fname'] to
"fname"

datafile.php has

fname: $_SESSION['fname'];
lname: $_SESSION['lname'];

I would like to automatically copy the data to

second.js

var fname = "fname";
var lname = "lname";

to be used in JavaScript.

I am familiar with
$contents = file_get_contents($filename);

and I know how to copy files but not data inside of the file.

Thanks for the help.

Ken

Hi Ken,

Have a look at:
http://nl2.php.net/manual/en/function.fopen.php

You will find a few examples and related functions over there.
It is not difficult.
1) Open a filehandle for the file to read.
2) Open a filehandle to the file to write to.
3) Walk though the first file and write stuff you want in the second file to
the second handle.
4) close both filehandles.

Good luck.
Regards,
Erwin Moller

Jul 17 '05 #2
Ken <kk******@wi.rr.com> wrote:
How do I copy data from one file to another? from $_SESSION['fname'] to
"fname"

datafile.php has

fname: $_SESSION['fname'];
lname: $_SESSION['lname'];

I would like to automatically copy the data to

second.js

var fname = "fname";
var lname = "lname";


You don't actually want to you copy that! fname and lname strike me like
lastname and firstname variables, so they are dependend on the user ->
session data.

So just serve the javascript by using php and you can use the session
data to dynmically set the values of [lf]name (don't forget to set hte
correct mimetype else strange things can happen).

Jul 17 '05 #3
"Ken" <kk******@wi.rr.com> wrote in message
news:yu*************@twister.rdc-kc.rr.com...
How do I copy data from one file to another? from $_SESSION['fname'] to
"fname"

datafile.php has

fname: $_SESSION['fname'];
lname: $_SESSION['lname'];

I would like to automatically copy the data to

second.js

var fname = "fname";
var lname = "lname";

to be used in JavaScript.

I am familiar with
$contents = file_get_contents($filename);

and I know how to copy files but not data inside of the file.


Just do something like

echo <<<JS
<script>
fname = {$_SESSION['lname']};
lname = {$_SESSION['lname']};
</script>
JS;

Linked in Javascript code run in the same context as the HTML page. You
don't need to set the variables in the .js file itself.
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: oceanhai | last post by:
We currently have a PPTP connection set up for our developers to access our development SQL server through a VPN tunnel. When they need to copy tables up to the dev SQL from their local machine...
5
by: tabonni | last post by:
Hello All I am creating an ASP page. There are a list of filename and checkbox next to it. When user checked all the documents they want and click ADD TO CLIPBOARD button. All filepaths will be...
6
by: Wayne Wengert | last post by:
I am using VSNET 2003 to build an ASP.NET/VB set of pages. There are currently about a dozen aspx pages. When I make even a minor change to one page I currently rebuild the solution, copy the...
5
by: DraguVaso | last post by:
Hi, I'm looking for a way to Copy and Paste Files to the clipboard. I found a lot of articles to copy pieces of text and bitmaps etc, but nog whole files. Whay I need is like you have in...
5
by: DraguVaso | last post by:
Hi, I need a SECURE way to copy parts of a file. I'm having files which contains a whole bunch of records. In one 'fysical' file I'm having one or more logical files. What I need to do is to...
2
by: Xavier Valdés | last post by:
Hi all, I would like to copy FILES from the clipboard to a desired folder from VB.NET. I was able to copy files (with filedrop data format) to the clipboard but I don't know how to catch this...
8
by: luis molina Micasoft | last post by:
it seems that when i do file.copy the svchost.exe is hanged, i mean if i make 40 threads of file.copy , 40 copys of files at same time the system is going down and stop responding, this is when i'm...
1
by: Byron | last post by:
Hi, I have(had) an old Win2k Server server with about 30 web site databases (SQL 2000) that just went under due to hardware problems. Thankfully, I have backups of all the databases plus the MDF...
1
by: aj | last post by:
DB2 LUW 8.2 FP14 Red Hat AS 2.1 I went to restore a backup of my production DB on my test/developmental server. The backup on the prod system was taken /before/ alt_obj() was used there to do...
1
by: dkmarni | last post by:
Hi, I am trying to do this perl script, but not able to complete it successfully. Here is the description what the script has to do.. Accept two and only two command line arguments. Again,...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.