perdue Posted October 4, 2008 Share Posted October 4, 2008 Hi, I'm working on a small script that creates a tab delimited text file of some information from a database. Currently the script is supposed to write to a file to create the headings row, then query the database for some information, and append that information to the headings row. It appends to the file three different times before reaching the end of the script. It works perfectly on my local machine, but after moving it to the server, I am getting a file open error. Here is the initial part that creates the headings: //prepare new export.txt for writing $myFile = "/pathtofile/export.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $headerData = "CODE\tNAME\tCATEGORIES\tATTRIBUTE_CODE\tATTRIBUTE_NAME\tOPTION_CODE\tOPTION_NAME\tPRICE\tCOST\tWEIGHT\tTAXABLE\n"; fwrite ($fh, $headerData); chmod('/pathtofile/export.txt', 0777); fclose($fh); It creates the file, with the headings, and the file permissions according to my ftp client are set to 777. However, when I try to open it to append the next set of data, I get an error. //open export.txt and append product data $myFile = "export.txt"; $fh = fopen($myFile, 'a') or die("can't open file"); $stringData = $proddata['code'] . "\t" . $proddata['name'] . "\t" . $categories . "\t" . "\t\t\t\t" . $price . "\t" . $proddata['cost'] . "\t" . $proddata['weight'] . "\t" . $proddata['taxable'] . "\n"; fwrite($fh, $stringData); fclose($fh); } I would appreciate any suggestions for what I may be doing wrong. As I said, it works perfectly on my local machine, so I'm assuming it's some sort of permissions problem??? Quote Link to comment https://forums.phpfreaks.com/topic/127023-solved-unable-to-open-file-to-append/ Share on other sites More sharing options...
wildteen88 Posted October 4, 2008 Share Posted October 4, 2008 It may be helpful if you included the error message produced. Quote Link to comment https://forums.phpfreaks.com/topic/127023-solved-unable-to-open-file-to-append/#findComment-657065 Share on other sites More sharing options...
perdue Posted October 4, 2008 Author Share Posted October 4, 2008 Oh how sad is this. I read over my post, and just realized in the second part, I have $myFile = "export.txt"; instead of $myFile = "/pathtofile/export.txt"; Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/127023-solved-unable-to-open-file-to-append/#findComment-657066 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.