Hi I have a php application which runs on an IIS Server and I want to create/append a file on an other server or PC Can I do it if I use fopen and I create a folder on that other server or PC which I grant write access to everyone or is it impossible? $handle = fopen("\\\W109-0422\\test\\test.txt");

Member Avatar
Member Avatar
+0 forum 2

I have two different text files, one of them contains a text, the other one works as a dictionary. The dictionary has some words line by line with their description beside them separated by a comma. I'm supposed to search for all these words in the text and then replace them with their description. I thought after opening both for reading, I should load their contents into two arrays, I'm just a bit confused about the dictionary part since it should be read line by line and then each line should be broken into two parts. **I just really need …

Member Avatar
Member Avatar
+0 forum 1

hi. i want to load and read a file in php. i wrotte this code but it doesn't work. i want when the user loads a txt file, then it will be shown in the page. i can use fopen but i dont know its directory for example. any help ? <input type="file" name="doc" /> $file = fopen($_FILES['doc'], "r") or exit("Unable to open file!"); //Output a line of the file until the end is reached while(!feof($file)) { echo fgets($file). "<br>"; } fclose($file); ?>

Member Avatar
Member Avatar
+0 forum 3

Hello guys, I'm trying to save/store data from a *form* to a *text file*. The problem is that the information sent from the form does not seem to be storing in the text file as whenever I enter its url the page is just empty. The code is as follows: The simple form (database.php) <form action = "ProcessFormData.php" method = "post"> Name <input type="text" name="name"> Age <input type="text" name="age"> <input type="submit" value="Go Go"> The php file that is supposed to transfer the form data onto the text file <?php $name = $_POST['name']; $age = $_POST['age']; $data = "$name ¦ $age\n"; …

Member Avatar
Member Avatar
+0 forum 17

Im trying to open a txt file to write into it . heres the warning : Warning: fopen(C:\inetpub\wwwroot\testFile.txt): failed to open stream: Permission denied in C:\inetpub\wwwroot\get.php and heres the code $fh = fopen("C:\\inetpub\\wwwroot\\testFile.txt" , 'w'); fwrite($fh, "PHP"); what am I missing ?

Member Avatar
Member Avatar
+0 forum 1

Hellou. Can anyone tell me how can i save a string to a file? I have this function: void PrintGameBoard(jogo_4line*jg) { int i,n; system("clear"); printf("===============Jogo do 4 em linha===============\n\n\n"); printf(" +--+--+--+--+--+--+--+\n"); for(i=1; i<=6; i++) { printf("%d |%c |%c |%c |%c |%c |%c |%c |\n",7-i,jg->T[i][1],jg->T[i][2],jg->T[i][3],jg->T[i][4],jg->T[i][5],jg->T[i][6],jg->T[i][7]); if (i!=0) printf(" +--+--+--+--+--+--+--+\n"); } printf(" "); for (n=1;n<=7;n++) printf(" %d",n); printf("\n"); } i need to save the contents of this function to a file. I mean, this fucntion prints the state of a game 4 in a row in my program. Then i have this function: int SaveGame( jogo_4line *game, char *save1) { FILE *fp; …

Member Avatar
Member Avatar
+0 forum 3

Ok. As the title says I tried many times to simply write a program that rewrites a file to remove null characters. I confirmed with a hex editor that the file in question has tons on null characters, on average about 1 of every 2 characters in null. So my last attempt: #include <stdlib.h> #include <stdio.h> int main() { FILE *f = fopen("main2.c","r"); FILE *t = fopen("temp","w"); int c; int count = 0; while((c = fgetc(f))!=EOF) { if(c) { fputc(c,t); } else { printf("null found\n"); } } fclose(f); fclose(t); FILE *n = fopen("main2.c","w"); FILE *w = fopen("temp","r"); while((c=fgetc(w))!=EOF) { fputc(c,n); …

Member Avatar
Member Avatar
+0 forum 10

Hi, I encounter an assertion error on my thesis while trying to write a line to a file. The related code is pasted below. The funny thing is that this code runs maybe 5000 times and i get the error at 5001 th time. Thank you very much for any help. Note: I checked if the paramters that are to be written are NULL, but they are not. outp = fopen("Results_lp.csv","w"); // All results will be written to Results.csv file if(noofstations==1) { fprintf(outp,"Problem;Instance;Number of Stations;Cycle Time;Objective Function Value;CPU Time;Number of Tasks\n"); } fprintf(outp,"%d; %d; %d; %d; %f; %.2f; %d;",problem, instance,noofstations,CT,objval,cpufix,N);

Member Avatar
Member Avatar
+0 forum 7

I'm having trouble opening a file using fopen in C++. I'm using XCode 4. Here's my code: FILE *f; f = fopen("test.txt", "r"); if (f == NULL) std::cout << "Error: NULL file"; When I run this, the error message gets printed. test.txt is stored in the same directory as my XCode project. I just want to be able to read from test.txt hence the "r." Any tips? Thanks.

Member Avatar
Member Avatar
+0 forum 2

it gets compiled but it crushes: "programm has stopped working" Please help me!!! this is the programm: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { FILE *fp; int i=0, n; char allwords[100][40]; fp=fopen("fraoules.txt","r"); if ( (fp=fopen("fraoules.txt","r") )==NULL ){ printf("To arxeio den mporese na anoixtei\n"); } while(strcmp( allwords[i],"telos")!=0){ fscanf(fp, "%s", allwords[i+1]); i++;} fclose(fp); for(n=0; n<i; n++) printf("%s", allwords[n]); system("PAUSE"); return 0; }

Member Avatar
Member Avatar
+0 forum 3

I have a project that, instead of using MySQL, I am supposed to use txt files to manage data. I have no say in this, I'm doing the project for a client. So I wrote a test file with functions for writing these data files, reading, etc. But it's not acting correctly. I call read the content of a file, let's say it has 1 line in it. I then call the function to write an entry to the file. I then read the contents of the same file again, but it still shows only the 1 entry. I then …

Member Avatar
Member Avatar
+0 forum 2

i'm working on visual studio 2008. I'm trying use fopen to open txt files and it does not give any errors but its not doing the required task either. i've to submit this project on monday! please help here's part of the code: [CODE]#include <stdio.h> #include<iostream> #include <conio.h> #include <string> #include <stdlib.h> #include<dos.h> using namespace std; FILE *file_ptr; node* treefromfile() { node *ptree=NULL; char word[20],meaning[100],str[120],*i; int flags=0; file_ptr=fopen("C:\Dictionary","r"); if(file_ptr==NULL) ptree=NULL; else { while(!feof(file_ptr)) { i=fgets(str,120,file_ptr); if(i==NULL) break; seperateword(str,word,meaning); if(flags==0) { ptree=maketree(word,meaning); flags=1; } else addword(ptree,word,meaning); }[/CODE]

Member Avatar
Member Avatar
+0 forum 7

Hi! I want to check if some file on some other server exists. I have this code (but something is wrong with it): [CODE]<?php $notworking=array(); $false=0; $link="http://uploads.mp3songurls.com/"; $files=glob("genre/*.xml"); foreach($files as $file){ $xml=new SimpleXMLElement($file,null,true); foreach($xml as $info){ if(fopen($link.$info->link.".mp3","r")==false){ $false++; $notworking[$false]=$info->name." => ".$info->author; } } } if($false>0){ $file=fopen("notworking.txt","w"); for($i=1;$i<=$false;$i++){ fwrite($file,$notworking[$i]."\r\n"); } fclose($file); echo "(some songs don't exist: <a href=\"javascript:void(0)\" onclick=\"window.open('notexist.php','popupWindow','height=500,width=600,left=30,top=40,toolbar=no,location=no,status=no,menubar=no,scrollbars=no');\">$false</a>)"; }else{ if(file_exists("notworking.txt")) unlink("notworking.txt"); echo "(everything's OK)"; } ?>[/CODE] I'm getting "(everything's OK)", but one file isn't OK (it doesn't exist). Is there some error in code or what? Thanks a lot! (PS. And with XML file is everything OK)

Member Avatar
Member Avatar
+0 forum 8

Hey very simple problem. I've been searching the site to see if I did anything wrong and I had to fail because I still get the wrong results (semantic error). Problem #1: Every time I use fopen with the "w" (or write) mode the file with whatever name given is not created which brings us to the second problem. Problem #2: Correct me if I am wrong (syntax might of changed due to updates), but as I know according to Dave Mark's "Learn C on the Mac" he specifies as filename paths as the following: All of the following are …

Member Avatar
Member Avatar
+0 forum 3

I tried to store several data an cant achieve it: [CODE] #include <iostream> #include <string.h> #include <stdlib.h.> #include <stdio.h> #include "estructura.h" void guardar_cliente(cliente x) { FILE*f; f= fopen("data.txt", "w"); fwrite(&x, sizeof(x), 1, f); fclose(f); } [/CODE] I dont know whats wrong im using another cpp file and a header file as you might have noticed, but the text file doesnt appear, whats wrong with this code pleeease help!!! im using vista btw

Member Avatar
Member Avatar
+0 forum 7

Hello, I have this assignment in C. The problem is that the functions have to be placed in separate files instead of just one. I haven't done that before. It seems code that would have run if the program was written in one file doesn't work when the functions are separated. Why? I've tried this on both Visual Studio 2005 and 2010 on Windows XP with the same result. Here's a small bit of code: main.c [CODE]#include <stdio.h> #include <stdlib.h> #include "my_func.h" int main() { FILE *fp; char s[30]; fp=fn_fop(); fn_out(&fp); fclose(fp); printf("\nsuccess\n"); return 0; }[/CODE] my_func.c [CODE]#include <stdio.h> #include …

Member Avatar
Member Avatar
+0 forum 2

Hi, Im guessing this is an easy piece of code, but i cant find the answer Im looking for anywhere. I have 20 files each with a different a list of numbers (not all the same amount of numbers). Each file is called data-01.txt, data-02.txt... to data-20.txt.I need to open each file, do the same calculation on each file and print out all the results. I was looking for a way to open each file by using a variable(i=1; i<=20; i++) rather than type in each, but can't seem to find one. Any help please?

Member Avatar
Member Avatar
+0 forum 10

Hi, Is it possible to stop the [i]fopen[/i] function from accessing a file or folder? My server uses linux but I have no control over [I].ini[/I] files as my host prevents me from accessing them. Is there any way from using a [I].htaccess[/I] or something to prevent [i]fopen[/i] from opening a file [B]BUT still allow them to be included[/B]. Isn't this strange ;) If it's not possible, please say. Kieran :)

Member Avatar
+0 forum 0

The End.