[PHP] PHP fopen function
Hi, I am developing a web application using PHP and I am facing a funny kind of problem with the PHP fopen function. I have a webscript, which has a function in which a file has to be opened in the directory of the webserver. The function takes the file path as a parameter. The fopen function fails, when the parameter is passed into the fopen function, but when I hardcode the same file name, the fopen function succeeds. I am sure it is not a permission problem, because I can open the same file when I hardcode its path. The php error log file says PHP Warning: fopen(/usr/local/base/data/rawdata/batchdata/testhyb2/Slide1.gpr) [http://www.php.net/function.fopen]: failed to create stream: No such file or directory in /usr/local/base/include/classes/wizzzard.inc.php on line 566 I would appreciate any suggestions or thoughts. Thank you, Sushmita -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP fopen function
Yes, I am calling the fopen with two parameters. The filename is also a string. The problem is when I pass a string variable the fopen fails but succeeds when I pass a constant string. Raditha Dissanayake wrote: Hi, fopen usually takes two arguments, the filenames is expected to be a string and check your register_globals settings. Sushmita Roy wrote: Hi, I am developing a web application using PHP and I am facing a funny kind of problem with the PHP fopen function. I have a webscript, which has a function in which a file has to be opened in the directory of the webserver. The function takes the file path as a parameter. The fopen function fails, when the parameter is passed into the fopen function, but when I hardcode the same file name, the fopen function succeeds. I am sure it is not a permission problem, because I can open the same file when I hardcode its path. The php error log file says PHP Warning: fopen(/usr/local/base/data/rawdata/batchdata/testhyb2/Slide1.gpr) [http://www.php.net/function.fopen]: failed to create stream: No such file or directory in /usr/local/base/include/classes/wizzzard.inc.php on line 566 I would appreciate any suggestions or thoughts. Thank you, Sushmita -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP fopen function
I just set the register_global to On. But that does not seem to make a difference. I know the parameters are being passed correctly because I am printing an error message when the file cannot be opened with the filename which is passed a parameter, and that is exactly what I had passed. Raditha Dissanayake wrote: Hi, what's your register global settings? If this is off (which is the most likely) the parameters that you pass across may not be intepreted correctly. Are you by any chance on any of these virtual hosting schemes like cpanle or ensim? their handling of file paths are rather wierd and that too could be effecting your script. Sushmita Roy wrote: Yes, I am calling the fopen with two parameters. The filename is also a string. The problem is when I pass a string variable the fopen fails but succeeds when I pass a constant string. Raditha Dissanayake wrote: Hi, fopen usually takes two arguments, the filenames is expected to be a string and check your register_globals settings. Sushmita Roy wrote: Hi, I am developing a web application using PHP and I am facing a funny kind of problem with the PHP fopen function. I have a webscript, which has a function in which a file has to be opened in the directory of the webserver. The function takes the file path as a parameter. The fopen function fails, when the parameter is passed into the fopen function, but when I hardcode the same file name, the fopen function succeeds. I am sure it is not a permission problem, because I can open the same file when I hardcode its path. The php error log file says -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php