473,508 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

fwrite argument resource problem

296 Contributor
Hello,

I wrote the below code :
Expand|Select|Wrap|Line Numbers
  1. fwrite(STDOUT, "Enter the email address: ");
and got the following error :
Expand|Select|Wrap|Line Numbers
  1. Warning: fwrite(): supplied argument is not a valid stream resource in C:\apache
  2. 2triad\php\bin\cPass.php on line 7
How to solve this problem ?
Mar 3 '08 #1
6 1333
ronverdonk
4,258 Recognized Expert Specialist
The 1st parameter of the fwrite() command ususally refers to a file system pointer resource that has been opened before with an fopen().

Is there any reason why you want this to write to STDOUT??

Ronald
Mar 3 '08 #2
pankajit09
296 Contributor
The 1st parameter of the fwrite() command ususally refers to a file system pointer resource that has been opened before with an fopen().

Is there any reason why you want this to write to STDOUT??

Ronald

I want to run the php file from the command prompt.
So I want to take the input from the user.

What to do ?
Mar 3 '08 #3
ronverdonk
4,258 Recognized Expert Specialist
Oh I see.
Are you sure that your Command Line Interface is available? Type
Expand|Select|Wrap|Line Numbers
  1. php -v
on the command line and it should indicate the presence in a form which looks something like
Expand|Select|Wrap|Line Numbers
  1. C:\wamp\bin\php\php5.2.5>php -v
  2. PHP 5.2.5 (cli) (built: Nov  8 2007 23:18:51)
  3. Copyright (c) 1997-2007 The PHP Group
  4. Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Do you have the CLI?

Ronald
Mar 3 '08 #4
pankajit09
296 Contributor
Oh I see.
Are you sure that your Command Line Interface is available? Type
Expand|Select|Wrap|Line Numbers
  1. php -v
on the command line and it should indicate the presence in a form which looks something like
Expand|Select|Wrap|Line Numbers
  1. C:\wamp\bin\php\php5.2.5>php -v
  2. PHP 5.2.5 (cli) (built: Nov  8 2007 23:18:51)
  3. Copyright (c) 1997-2007 The PHP Group
  4. Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Do you have the CLI?

Ronald

Yes its available.

Expand|Select|Wrap|Line Numbers
  1. PHP 4.4.2 (cgi-fcgi) (built: Jan 13 2006 13:53:43)
  2. Copyright (c) 1997-2006 The PHP Group
  3. Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
  4.     with Zend Optimizer v2.6.2, Copyright (c) 1998-2006, by Zend Technologies
What is a CLI ?
Mar 4 '08 #5
ronverdonk
4,258 Recognized Expert Specialist
CLI is the Command Line Interface. There are some differences between the CLI and the CGI (the one you have installed). Depending on the version of PHP you are running, calling the PHP via the command line is different. An example from the documentation:
Starting with PHP 5, the CLI is distributed in the main folder, named php.exe. The CGI version is distributed as php-cgi.exe. The Windows packages between PHP 4.2.0 and PHP 4.2.3 distributed the CLI as php-cli.exe, living in the same folder as the CGI php.exe. Starting with PHP 4.3.0 the Windows package distributes the CLI as php.exe in a separate folder named cli, so cli/php.exe ....
For a detailed explanation you'd better have a look at the PHP manual's chapter Using PHP from the command line whete it is all explained.

Ronald
Mar 4 '08 #6
pankajit09
296 Contributor
CLI is the Command Line Interface. There are some differences between the CLI and the CGI (the one you have installed). Depending on the version of PHP you are running, calling the PHP via the command line is different. An example from the documentation:
For a detailed explanation you'd better have a look at the PHP manual's chapter Using PHP from the command line whete it is all explained.

Ronald

CLI works here since I can execute php scripts from command line.
Mar 4 '08 #7

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

Similar topics

3
2435
by: Antoine Bloncourt | last post by:
Hello everybody Sorry to bother you but I have a problem writing datas into a file ... I want to make a backup of my MySQL database and put the result into a ..sql file. To do this, I use...
4
2601
by: Andrew Kibler | last post by:
Two sections of code, in the first one fwrite works, in the second one it doesn't (ms VC++) both are identical except in the working one fseek is used twice to set the file pointer, once just...
8
15344
by: Brady | last post by:
Hi, I'm having a problem reading and writing to a file. What I'm trying to do is read a file, modify the portion of the file that I just read, and then write the modified data back to the same...
23
17811
by: FrancisC | last post by:
how to use fwrite( ) instead of fprintf( ) in this case? I want to generate binary file. FILE *fnew; int i, intName; double array; fprintf(fnew, "%d\n", intName);...
17
6103
by: SW1 | last post by:
I wrote a small program which does something like tftp - transfering files and some chat, anyway i got a problem with fwrite, here is a snippet of my code: while(length > 0) { putchar('.');...
15
3850
by: Suraj Kurapati | last post by:
Hello, I'm having a rather strange bug with this code: for certain values of 'buf', a segmentation fault occurs when 'free(buf)' is followed by an 'fwrite()'. In the program output, there is no...
2
6296
by: Richard Hsu | last post by:
// code #include "stdio.h" int status(FILE * f) { printf("ftell:%d, feof:%s\n", ftell(f), feof(f) != 0 ? "true" : "false"); } int case1() { FILE * f = fopen("c:\\blah", "wb+"); int i = 5;
11
4260
by: David Mathog | last post by:
In the beginning (Kernighan & Ritchie 1978) there was fprintf, and unix write, but no fwrite. That is, no portable C method for writing binary data, only system calls which were OS specific. At...
2
2025
by: alexus | last post by:
fwrite(fopen('temp.xml','w+'), print_r(simplexml_load_string(curl_exec($test))),true); i for some reason get "1" inside of my temp.xml
0
7229
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
7333
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
7398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7061
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7502
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...
1
5057
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
3208
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
1566
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 ...
0
428
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.