473,480 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

File remains empty

10 New Member
Hi, I was trying the following code from a SAMS book. It is supposed to write some output to the purchase.txt file after formatting it through the column application . the file gets created but nothing gets written to it for some reason. Can someone please explain?


Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $products = array(
  3.                   array("HAL 2000", 2, "red"),
  4.                   array("Tricorder", 3, "blue"),
  5.                   array("ORAC AI", 1, "pick"),
  6.                   array("Sonic Screwdriver", 1, "orange")
  7.                   );
  8. $handle = popen("column -tc 3 -s / > purchase.txt", "w");
  9. foreach ($products as $p){
  10.     //fputs($handle, join('/', $p). "\n");
  11. }
  12.  
  13. pclose($handle);
  14. echo "done";
  15. ?>
Apr 19 '10 #1
3 1142
Atli
5,058 Recognized Expert Expert
Hey.

Have you tried un-commenting line #10?

If yes, try turning on the Debug Messages and see if an error is being suppressed.
Apr 19 '10 #2
sayub
10 New Member
Oh sorry, that was just a slip, in the real code that line is not commented. Please help...
Apr 19 '10 #3
Atli
5,058 Recognized Expert Expert
Ok.

I'm guessing this is a permission problem. The popen command can not tell whether the column command is actually able to write to the output file, so even if there is a permission problem, odds are that you will see no error.

Try using the is_writable function on the file before trying to write to it, to make sure you have access. If it turns out you don't have access to it, you can try to use the chmod command to alter the access, or log in via FTP (or whatever you use) and change it manually.
Apr 20 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
9802
by: Oliver Knoll | last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode (that is just writing, right?). How would one reopen it for reading? I got the following (which works): FILE *tmpFile =...
28
9541
by: Colin JN Breame | last post by:
Hi, Fairly new to C. What is the best way to read a line (\n terminated) from a file? Ive looked at fscanf but was not sure which format specifier to use. (%s perhaps). Thanks Colin
15
4734
by: ruca | last post by:
Hi, Can I read a .TXT File to a DataSet? How can I do that? I want to read his lines to a DropDownList. This lines are the names of employees that I export from an application that I have. I...
2
4658
by: crusell | last post by:
I'm having some problem with my Visual Studio.NET 2003 (.NET 1.1 SP1) install. I am unable to use the web forms designer with any aspx file whose form class inherits from a base class. I'm...
55
25413
by: Sameer | last post by:
Hi, when i compile my C programs (even 2 line progs) give the warning, no new line at end of file. What does this mean ? -Regards, Sameer
2
5726
by: john_aspinall | last post by:
Here's the overview: Im building an eCommerce web site using ASP. It has an Access DB at the back end. Im receiving the Product info from a series of CSV files. Ive created a Table in Access...
13
4158
by: DH | last post by:
Hi, I'm trying to strip the html and other useless junk from a html page.. Id like to create something like an automated text editor, where it takes the keywords from a txt file and removes them...
1
5533
by: emailseshu | last post by:
Hi, Iam trying to check the Client Side CallBack Feature in ASP.NET Iam able to call th RaiseCallbackEvent from the Client Side Javascript Function but when I go to the debug mode to check the...
2
1714
by: Rene | last post by:
Hello to all! I am a newbee to C++, I did a beginners' course, and now I am stuck with a strange problem. I have written the function that is pasted downwards. The peculiar thing is that when...
7
1994
by: Andrew Jocelyn | last post by:
Hi I'm running an ASP.NET web application under IIS. I'm inserting a cache object with a file based CacheDependency. I've noticed that when the file changes the Cache object is not always...
0
7049
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7052
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
6981
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5348
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,...
1
4790
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3000
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...
0
1304
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 ...
1
565
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
188
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...

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.