fwrite argument resource problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pankajit09
    Contributor
    • Dec 2006
    • 296

    fwrite argument resource problem

    Hello,

    I wrote the below code :
    Code:
    fwrite(STDOUT, "Enter the email address: ");
    and got the following error :
    Code:
    Warning: fwrite(): supplied argument is not a valid stream resource in C:\apache
    2triad\php\bin\cPass.php on line 7
    How to solve this problem ?
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    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

    Comment

    • pankajit09
      Contributor
      • Dec 2006
      • 296

      #3
      Originally posted by ronverdonk
      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 ?

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

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

        Ronald

        Comment

        • pankajit09
          Contributor
          • Dec 2006
          • 296

          #5
          Originally posted by ronverdonk
          Oh I see.
          Are you sure that your Command Line Interface is available? Type
          Code:
          php -v
          on the command line and it should indicate the presence in a form which looks something like
          Code:
          C:\wamp\bin\php\php5.2.5>php -v
          PHP 5.2.5 (cli) (built: Nov  8 2007 23:18:51)
          Copyright (c) 1997-2007 The PHP Group
          Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
          Do you have the CLI?

          Ronald

          Yes its available.

          Code:
          PHP 4.4.2 (cgi-fcgi) (built: Jan 13 2006 13:53:43)
          Copyright (c) 1997-2006 The PHP Group
          Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
              with Zend Optimizer v2.6.2, Copyright (c) 1998-2006, by Zend Technologies
          What is a CLI ?

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            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:
            Originally posted by php docs
            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

            Comment

            • pankajit09
              Contributor
              • Dec 2006
              • 296

              #7
              Originally posted by ronverdonk
              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.

              Comment

              Working...