473,770 Members | 4,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

changing old values to new values

I just would like to re-explain the problem i am having as i had not
received any posts, so i might of explained in poorly.

The problem i am having is NOT parse error related, more or less a
problem in my logic. Ok , well what is happening is i am getting my
values in member.txt fields ok from reading it, but when i attempted
to write those values back to the member.txt file with updated string
values, my member.txt file is cleared of all values, and i think my
array is been wiped.

Here is the updated code:

if(isset($_POST['Submit']))
{

//Store profile in username.txt
$fileName .= "../username/member";
$fileName .= $_POST['user_id'];
$fileName .= ".txt";
$handle = fopen($fileName , "w");
fwrite($handle, $_POST['form1']);
fclose($handle) ;

// build record into string from post values
$update = $_POST['user_id'] . "|" . $_POST['password'] . "|" .
$_POST['lastname'] . "|" . $_POST['firstname'] . "|"

$fileName = "../username/member.txt";
//set line to edit
//get file into an array
$contents=file( $fileName);
//set the file name

$edit_line = $_GET['record_id'];
//replace original record with new record
$replace_text =$update;

// replace specified array index (user to update) with built string
$contents[$edit_line] = $replace_text;
// Strip carrage-returns
for($c = 0; $c < count($contents )-1; $c++)
{
$contents[$c] = str_replace( "n", "", $contents[$c] );

}
// write array to file
if (!$fp = fopen($fileName ,"w")) { die("Cannot open file"); }

if($_GET['record_id']==$contents[$edit_line])
fwrite($fp,impl ode("n",$conten ts));
//fwrite($fp,$str );
fclose($fp);

}
else
{
if(!isset($_POS T[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];
}
}

?>

Cheers,
Peri

Apr 19 '07 #1
2 1518
| // Strip carrage-returns
| for($c = 0; $c < count($contents )-1; $c++)
| {
| $contents[$c] = str_replace( "n", "", $contents[$c] );
|
| }

you do realize that this may be your problem?

it should be str_replace("\n ", '', $contents[$c]) ...otherwise, you're just
stripping the letter 'n'. likewise, later when you implode $contents, you
concatenate the records with the letter 'n' again. what i don't understand
is why you are stripping \n anyway since you implode using \n. why not just
make $update/$replace_text end with \n, replace the correct element and be
done with it. your implode can simply implode('', $contents)...si nce \n is
already inclusive given that you use file().

does that help?
Apr 19 '07 #2
On 19.04.2007 03:02 programming wrote:
I just would like to re-explain the problem i am having as i had not
received any posts, so i might of explained in poorly.

The problem i am having is NOT parse error related, more or less a
problem in my logic. Ok , well what is happening is i am getting my
values in member.txt fields ok from reading it, but when i attempted
to write those values back to the member.txt file with updated string
values, my member.txt file is cleared of all values, and i think my
array is been wiped.

The wheel you're trying to invent is called "database" and it would be
wise to use an existing one (mysql, sqlite etc) rather than code your own.

--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
Apr 19 '07 #3

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

Similar topics

3
6646
by: Cengiz Ulku | last post by:
Hi all, I know now how to change the font name of a RTF file in a RTB control using, for example: RTextBox1.SelFontName = cmbFonts.Text I have a RTF file -created with Word- displayed in a RTB control. Whenever I change the font type during the runtime by selecting a font name from a combobox -of all system fonts, the text changes its font correctly but I loose some formatting such as a bold text and/or titles become normal text.
5
1669
by: martin | last post by:
I needed a way to display calculated, multiple, changing values (numerical sums) as users interacted with the page, and do this without going back to the server to load the page again. What I finally settled on was <input type=button...> without an "onClick" attribute (because the purpose of the buttons was only for displaying values). It works fine except they look and act like buttons. No big deal, but is there a better way?
3
4591
by: Jeff | last post by:
Hi I have a report with a graph on it and want to change the minimum and maximum values for the value axis when it is previewed. This can't be done by adding code in the Open event as once the report has started printing the properties can't be changed. It can be done with an MDB by opening it in design mode hidden, making the change, saving it and then opening it in preview mode. However, this obviously doesn't work in an MDE which...
3
1980
by: Jeremy Ames | last post by:
I have a form that contains two hidden values, among other controls. I was wondering, if I change these values in server script and immediately do a server.transfer, do these values get updated before the page is changed? I want to say that because the values are changed but the page is never reloaded after the change, that these changes do not take effect before the server.transfer. Please let me know if I am correct here. I think I am...
3
1879
by: kurt sune | last post by:
I am running the native debugger in Visual Studio. I debug an assembly calling DLL:s made in VB6. I can watch the values of variables thus: ?Number 0x06e1960c "300115"
7
4034
by: Jeffrey Spoon | last post by:
Hello, I'm a bit stuck trying to convert a text file which contains extended ASCII text and changing the ASCII values so they become readable. I do this by subtracting 127 from the ASCII value. However, at the moment I am just getting more gibberish so I'm probably doing something wrong. I tried using ASCII Encoding before to get the ASCII values. Although this worked for 0-127 ASCII values, extended ASCII gave strange values (such as 1992...
2
6996
by: John | last post by:
Hi Everyone, I have a question about dynamically changing the length of a varchar(n) field, in case the value I'm trying to insert is too big and will give a "truncated" error, but before the error is given! i.e. Is there some kind of a way to "test" the length of the field while Inserting the value into it, and to have it automatically increase its length to the length of the value being inserted, in case the value is too big? I've...
1
1244
by: sathyan8294 | last post by:
what is vb.net code for changing the values in datagrid and save the changed values using vb.net windows application
6
18425
by: troy_lee | last post by:
I have a continuous form that has one combo box (cbo1) with the selectable values of "Removal" and "Installation". I would like to change another combo box (cbo2) value list based on the selection in cbo1. For example, when the user selects "Removal" from cbo1 I would like the value list of cbo2 to be one set of values and when "Installation" is selected in cbo1 I would like the value list of cbo2 to be a different set of values.
3
1591
by: mileshenley | last post by:
Hey there, This may be an ASP question but i think it is more of a JS question. I have a web form that i want to have database values loaded into. I have (and want) the form defaulting to unfilled. I now have it checking and updating most the fields if a recordId is added into the url using ASP. My problem lies in changing the radio values. Here are some snipets of what I have to try to do this that isn't working. -here is how i have...
0
10053
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10001
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5312
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3969
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3573
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.