Search Results

Search found 616 results on 25 pages for 'fopen'.

Page 1/25 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • mysql UDF : fopen = permission denied

    - by lindenb
    Hi All, this is question I already asked on SO but I wonder if this could be a SysAdmin problem. I'm trying to create a mysql UDF function , this function calls "fopen/fclose" to read a flat file stored in /data. But using errno (yes, I know it is bad in a MT program...) I can see that the function cannot open my file: "Permission denied" I tried to do a chmod -R 755 /data (as well as 777, chown -R mysql:mysql /data etc...) but it didn't change anything. when I copied the flat file to /tmp : OK, my UDF was able to 'fopen' the file. I'm puzzled. currently , I've got: drwxrwxrwx 4 pierre root 4096 2010-05-26 16:51 /data drwxrwxrwx 3 pierre root 4096 2010-05-18 09:41 /data/dir1 drwxrwxrwx 3 pierre root 4096 2010-05-18 09:41 /data/dir1/dir2 drwxrwxrwx 4 pierre root 4096 2010-05-18 10:27 /data/dir1/dir2/dir3 -rw-r--r-- 1 pierre root 50685268 2005-12-10 00:01 /data/dir1/dir2/dir3/myfile.txt Any idea ?

    Read the article

  • PHP fopen returning null on files that work fine with include and get_file_contents

    - by brad allred
    Hi, I have XAMPP installed on a windows 2000 server. everything is working great except the PHP fopen function. I can neither create nor open files with it. the strange thing is that i can include/require/file_get_contents/other file related functions; also fopen does not generate any errors or notices it just returns NULL. I have gone as far as to grant full control of the file and all enclosing folders to everybody but i still get NULL instead of a file pointer. I have tried this on php 5.2.9, 5.2.13, and 5.3.1 with the same effect. i have gone through the php.ini file looking for something that is breaking it; i have even tried deleting and using the basic ini file from a linux box where fopen is working and still nothing. I know i have to restart apache after changing my ini and all that and have been (I have even restarted the server) so thats not it. I am at this poing assuming it is an apache configuration issue somehow, tomorrow im going to run a test through php-cli to make sure. I really don't want to bruise my head anymore over this can some apache/php wizard come to my aid? Hi guys, thanks for the responses. you are right is is not any config problem. the problem has to be with one of my dlls or one of my included files. I just tried the same code that isn't working in a new file without any include and i disabled my custom libraries and it worked. for the record here is what I was doing that wasn't working: $test_file = 'c:\\test.csv';//everybody has full control. is very large. if(file_exists($test_file) && is_readable($test_file)){ $fp = fopen($test_file, 'r'); echo var_export($fp, true);//outputs NULL. on my linux box this is a number. if($fp !== false){ //do the work fread($fp, 10);//throws the error that $fp is not a valid file handle } } something that i am including must be breaking fopen somehow. works as expected in new file with no includes.

    Read the article

  • PHP's fopen is terminally failing

    - by Skittles
    Okay, I have GOT to be missing something totally rudimentary here. I have an extremely simple use of PHP's fopen function, but for some reason, it will not open the file no matter what I do. The odd part about this is that I use fopen in another function in the same script and it's working perfectly. I'm using the fclose in both functions. So, I know it's not a matter of a rogue file handle. I have confirmed the file's path and the existence of the target file also. I'm running the script at the command-line as root, so I know it's not apache that's the cause. And since I am running the script as root, I am fairly confident that permissions are not the issue. So, what on earth am I missing here? function get_file_list() { $file = '/home/site/tmp/return_files_list.txt'; $fp = fopen($file, 'r') or die("Could not open file: /home/site/tmp/return_files_list.txt for reading.\n"); $files_list = array(); while($line = fgets($fp)) { $files_list[] = $line; } fclose($fp); return $files_list; } function num_records_in_file($filename) { $fp = fopen( $filename, 'r' ); # or die("Could not open file: $filename\n"); $counter = 0; if ($fp) { while (!feof( $fp )) { $line = fgets( $fp ); $arr = explode( '|', $line ); if (( ( $arr[0] != 'HDR' && $arr[0] != 'TRL' ) && $arr[0] != '' )) { ++$counter; continue; } } } fclose( $fp ); return $counter; } As requested, here's both functions. The second function is passed an absolute path to the file. That is what I used to confirm that the file is there and that the path is correct.

    Read the article

  • fopen() fails to open stream: permission denied, yet permissions should be valid

    - by about blank
    So, I have this error: Warning: fopen(/path/to/test-in.txt) [function.fopen]: failed to open stream: Permission denied Performing ls -l in the directory where test-in.txt is produces the following output: -rw-r--r-- 1 $USER $USER 1921 Sep 6 20:09 test-in.txt -rw-r--r-- 1 $USER $USER 0 Sep 6 20:08 test-out.txt In order to get past this, I decided to perform the following: chgrp -R www-data /path/to/php/webroot And then did: chmod g+rw /path/to/php/webroot Yet, I still get this error when I run my php5 script to open the file. Why is this happening? I've tried this using LAMP as well as cherokee through CGI, so it can't be this. Is there a solution of some sort? Edit I'll also add that I'm just developing via localhost right now. Update - PHP fopen() line $fullpath = $this->fileRoot . $this->fileInData['fileName']; $file_ptr = fopen( $fullpath, 'r+' ); I should also mention I'd like to stick with Cherokee if possible. What's this deal about setting file permissions for Apache/Cherokee?

    Read the article

  • How exactly does fopen(), fclose() work?

    - by user625672
    Hi, I was just wondering about the functions fopen, fclose, socket and closesocket. When calling fopen or opening a socket, what exactly is happening (especially memory wise)? Can opening files/sockets without closing them cause memory leaks? And third, how are sockets created and what do they look like memory wise? I'm also interrested in the role of the operating system (Windows) in reading the sockets and sending the data.

    Read the article

  • Creating new folders if they don't exist for fopen

    - by Gbps
    I have a C++ program that takes user input for fopen in order to initiate a file write. Could someone help me find a function which will return a FILE* and use the Windows specific version of mkdir in order to create the folder structure for fopen to never fail to open a new file in the specified location because one of the folders does not exist. Thanks a bunch!

    Read the article

  • Windows [C++] - Creating new folders if they don't exist for fopen

    - by Gbps
    I have a C++ program that takes user input for fopen in order to initiate a file write. Could someone help me find a function which will return a FILE* and use the Windows specific version of mkdir in order to create the folder structure for fopen to never fail to open a new file in the specified location because one of the folders does not exist. Thanks a bunch!

    Read the article

  • fopen doesn’t create file in the current directory

    - by indira
    I have created a console application in VS2010 and I want to create a file in the current directory where the exe runs. I used the following code fp = fopen("Pkts.csv", "w+"); But file is not getting created in the current directory. But when I specifies the path as fp = fopen("C:\\Windows\\Pkts.csv", "w+"); the file gets created in the path specified. How to create the file in the current directory?

    Read the article

  • Passing char * into fopen with C.

    - by Rhys
    Hey there, I'm writing a program that passes data from a file into an array, but I'm having trouble with fopen (). It seems to work fine when I hardcode the file path into the parameters (eg fopen ("data/1.dat", "r");) but when I pass it as a pointer, it returns NULL. Note that line 142 will print "data/1.dat" if entered from command line so parse_args () appears to be working. 132 int 133 main(int argc, char **argv) 134 { 135 FILE *in_file; 136 int *nextItem = (int *) malloc (sizeof (int)); 137 set_t *dictionary; 138 139 /* Parse Arguments */ 140 clo_t *iopts = parse_args(argc, argv); 141 142 printf ("INPUT FILE: %s.\n", iopts->input_file); /* This prints correct path */ 143 /* Initialise dictionary */ 144 dictionary = set_create (SET_INITAL_SIZE); 145 146 /* Use fscanf to read all data values into new set_t */ 147 if ((in_file = fopen (iopts->input_file, "r")) == NULL) 148 { 149 printf ("File not found...\n"); 150 return 0; 151 } Thanks! Rhys

    Read the article

  • Using fopen and str_replace to auto fill a select option

    - by Anders Kitson
    Hi Everyone, I have this file 'gardens.php', which pulls data from a table called 'generalinfo' and I use fopen to send that data to a file called 'index.html'. Here is the issue, only one option is filled. I have a demo running here Garden Demo <-- this is a new updated page and location, there are more errors than I have locally If anyone could help me fix them Username:stack1 Password:stack1 Is there a better way to achieve what I want to? Thanks! Always. GARDENS.PHP <?php include("connect.php"); $results = mysql_query("SELECT * FROM generalinfo"); while($row = mysql_fetch_array($results)){ $country = $row['country']; $province = $row['province']; $city = $row['city']; $address = $row['address']; //echo $country; //echo $province; //echo $city; //echo $address; } $fd = fopen("index.html","r") or die ("Can not fopen the file"); while ($buf =fgets($fd, 1024)){ $template .= $buf; } $template = str_replace("<%country%>",$country,$template); echo $template; ?> INDEX.PHP SNIPPET <form name="filter" method="get" action="filter.php"> <select class="country" name="country"> <option><%country%></option> </select> </form>

    Read the article

  • fopen / fopen_s and writing to files

    - by yCalleecharan
    Hi, I'm using fopen in C to write the output to a text file. The function declaration is (where ARRAY_SIZE has been defined earlier): void create_out_file(char file_name[],long double *z1){ FILE *out; int i; if((out = fopen(file_name, "w+")) == NULL){ fprintf(stderr, "* Open error on output file %s", file_name); exit(-1); } for(i = 0; i < ARRAY_SIZE; i++) fprintf(out, "%.16Le\n", z1[i]); fclose(out); } My questions: On compilation with MVS2008 I get the warning: warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. I haven't see much information on fopen_s so that I can change my code. Any suggestions? Can one instruct fprintf to write at desired precision? If I'm using long double then I assume that my answers are good till 15 digits after the decimal point. Am I right? Thanks a lot...

    Read the article

  • Performance of fopen vs stat

    - by Alex Marshall
    Hello, I'm writing several C programs for an embedded system where every bit of performance we can squeeze out will matter. Part of that is accessing log files. When determining if a file exists, is there any performance difference between using open / fopen, and stat ? I've been using stat on the assumption that it only has to do a quick check against the file system, whereas fopen would have to actually gain access to a file and manipulate internal data structures before returning. Is there any merit to this ?

    Read the article

  • How to get fopen to timeout properly

    - by beagleguy
    hey all, I have the following snippet of php code if($fp = fopen($url, 'r')) { stream_set_timeout($fp, 1); stream_set_blocking($fp, 0); } $info = stream_get_meta_data($fp); I'd like the request to timeout after 1 second... if I put a sleep(20) in my $url that I'm reading it just waits the whole 20 seconds and never times out. Is there a better way to do timeouts with fopen? If I use ini_set('default_socket_timeout',2); above that code it times out properly but $info then becomes null so ideally I'd like to use the stream functions. thanks

    Read the article

  • php fopen function dies, though I have file permissions set to read and write

    - by Matthew Robert Keable
    I'm following a tutorial on php, and am having difficulty getting this to work. I set the appropriate directory permissions to read and write, but every time I run this, I get the die string. The code is: $ourFileName = "testFile.txt"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle); As far as my basic understanding goes, if "testFile.txt" does not exist, fopen should create that file (I have basic knowledge of Python, and remember this same principle in that language). But it...it doesn't. Even if I create the aforementioned file, and put it up, that line of code still returns a die string. My hosting account does not give me permission to execute. Is this a problem? My server runs on Windows. I am using Dreamweaver CS5, on OSX 10.5.8. I've done some searching on this, and see other people having similar issues - but none of them keyed to exactly my range of problems. Being that I'm a beginner, I feel that it might be something I'm overlooking. Thanks!!

    Read the article

  • file doesn't open using PHP fopen

    - by jesop
    i have tried this: <?php $fileip = fopen("test.txt","r"); ?> this should have opened the file in read only mood but it doesn't the test.txt file is in same folder as that of index.php (main project folder) the file doesn't open and when i put echo like : echo $fileip; it returned Resource id #3

    Read the article

  • fopen create new file that not exists

    - by user306449
    Hey, I am trying to either create a file that doesn't exist or write to a file that already does. within a php file I am trying this: $file = fopen("data.txt", "a"); fwrite($file, "\n" . $name); fwrite($file, "," . $lastname); fwrite($file, "," . $email); fclose($file); I am running Apache under windows Xp and have no luck that the file "data.txt" is being created. The docs say that adding the a parameter should create a file with a name mentioned in the fist parameter (data.txt). what am I doing wring here? Thanks in advance undersound

    Read the article

  • C++ - Opening a file inside a function using fopen

    - by Josh
    I am using Visual Studio 2005 (C++). I am passing a string into a function as a char array. I want to open the file passed in as a parameter and use it. I know my code works to an extent, because if I hardcode the filename as the first parameter it works perfectly. I do notice if I look at the value as a watch, the value includes the address aside the string literal. I have tried passing in the filename as a pointer, but it then complains about type conversion with __w64. As I said before it works fine with "filename.txt" in place of fileName. I am stumped. void read(char fileName[50],int destArray[MAX_R][MAX_C],int demSize[2]) { int rows=0; int cols=0; int row=0; int col=0; FILE * f = fopen(fileName,"r"); ...

    Read the article

  • fopen in C(Linux) returns "Too many open files"

    - by liv2hak
    static char filename[128] = "trace.txt"; g_file = fopen(filename, "w"); if(NULL == g_file) { printf("Cannot open file %s.error %s\n",filename,strerror(errno)); exit(1); } I am trying to open a empty text file named trace.txt in write mode (in my working directory.) The program is creating an empty file trace.txt in my directory.but the check (NULL == g_file) is returning true and it is returning error code 24 (Too many open files.).Any idea why this is.This is the first file I am opening in my program.

    Read the article

  • PHP5 giving failed to open stream: HTTP request failed error when using fopen.

    - by mickey
    Hello everyone. This problem seems to have been discussed in the past everywhere on google and here, but I have yet to find a solution. A very simple fopen gives me a PHP Warning: fopen(http://www.google.ca): failed to open stream: HTTP request failed!". The URL I am fetching have no importance because even when I fetch http://www.google.com it doesnt work. The exact same script works on different server. The one failing is Ubuntu 10.04 and PHP 5.3.2. This is not a problem in my script, it's something different in my server or it might be a bug in PHP. I have tried using a user_agent in php.ini but no success. My allow_url_fopen is set to On. If you have any ideas, feel free!

    Read the article

  • php fopen => 500 Internal Server Error

    - by Ahmed B
    I have a website hosted on a dedicated server, I noticed that Google and other search engines can't access to the most URLs on my website!! On my localhost I have made a small test : var_dump(fopen('http://www.aswat.ma', 'r')); And I got this error : Warning: fopen(http://www.aswat.ma) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in C:\xampp\htdocs\pnowate\public\index.php on line 4 bool(false) If I change the URL "http://www.aswat.ma" by "www.google.co.ma" I got this : resource(3) of type (stream) Any one have any idea about this issue ??

    Read the article

  • How can I force PHP's fopen() to return the current version of a web page?

    - by Edward Tanguay
    The current content of this google docs page is: However, when reading this page with the following PHP fopen() script, I get an older, cached version: I've tried two solutions proposed in this question (a random attribute and using POST) and I also tried clearstatcache() but I always get the cached version of the web page. What do I have to change in the following script so that fopen() returns the current version of the web page? <?php $url = 'http://docs.google.com/View?id=dc7gj86r_32g68627ff&amp;rand=' . getRandomDigits(10); echo $url . '<hr/>'; echo loadFile($url); function loadFile($sFilename) { clearstatcache(); if (floatval(phpversion()) >= 4.3) { $sData = file_get_contents($sFilename); } else { if (!file_exists($sFilename)) return -3; $opts = array('http' => array( 'method' => 'POST', 'content'=>'' ) ); $context = stream_context_create($opts); $rHandle = fopen($sFilename, 'r'); if (!$rHandle) return -2; $sData = ''; while(!feof($rHandle)) $sData .= fread($rHandle, filesize($sFilename)); fclose($rHandle); } return $sData; } function getRandomDigits($numberOfDigits) { $r = ""; for($i=1; $i<=$numberOfDigits; $i++) { $nr=rand(0,9); $r .= $nr; } return $r; } ?>

    Read the article

  • Why would fopen fail to open a file that exists?

    - by void
    I'm on Windows XP using Visual Studio 6 (yes I know it's old) building/maintaining a C++ DLL. I'm encountered a problem with fopen failing to open an existing file, it always returns NULL. I've tried: Checking errno and _doserrno by setting both to zero and then checking them again, both remain zero, and thus GetLastError() reports no errors. I know fopen isn't required to set errno when it encounters an error according to a C standard. Hardcoding the file path, which are not relative. Tried on another developers machine which the same result. The really strange thing is CreateFile works and the file can be read with ReadFile. We believe this works in a release build, however we are also seeing some very odd behaviour in other areas of the application and we're not sure if this is related. The code is below, I don't see anything odd it looks quite standard to me. The source file hasn't changed for just under half a year. HRESULT CDataHandler::LoadFile( CStdString szFilePath ) { //Code FILE* pFile; if ( NULL == ( pFile = fopen( szFilePath.c_str(), "rb") ) ) { return S_FALSE; } //More code }

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >