472,992 Members | 3,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 software developers and data experts.

POST method doesn't work in PHP on the command line


I am using the php4-cgi Debian package which is based on PHP 4.3.4.

I have problems when running php4 on the command line. If I say something
like

$ php4 index.cgi

a number of variables are not initialized. For example, $HTTP_GET_VARS is
not set. To get it set, here's my workaround:

global $HTTP_GET_VARS;
parse_str(getenv("QUERY_STRING"),$HTTP_GET_VARS);

But, my real problem is that $HTTP_POST_VARS is not set -- I have no easy
workaround for that. If I set the REQUEST_METHOD environment variable to
"POST" and CONTENT_LENGTH to some value, the above command ("php4
index.cgi") does not read the post data from the standard input, as one
would suppose.

If I can successfully get the above missing variables to be defined when
on the command line, I should be able to figure out why php4 CGI scripts
don't work from thttpd. (Interestingly, php3 scripts work fine.)
(Ultimately, I would like to get phpwiki to work on thttpd, but I think
the above problems are unrelated to this combination per-se. Note that
phpwiki requires that register_globals be set to "on" to work.)

Just for the record, here's the output from "php4 -i":
phpinfo()
PHP Version => 4.3.4

System => Linux darkstar 2.4.19 #10 Wed Sep 11 15:45:42 EDT 2002 i686
Build Date => Mar 27 2004 08:01:43
Configure Command => '../configure' '--prefix=/usr' '--prefix=/usr' '--with-regex=php' '--enable-force-cgi-redirect' '--with-config-file-path=/etc/php4/cgi' '--disable-rpath' '--enable-memory-limit' '--disable-debug' '--with-layout=GNU' '--with-pear=/usr/share/php' '--enable-calendar' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-trans-sid' '--enable-bcmath' '--with-bz2' '--enable-ctype' '--with-db4' '--with-iconv' '--enable-exif' '--enable-filepro' '--enable-ftp' '--with-gettext' '--enable-mbstring' '--with-pcre-regex=/usr' '--enable-shmop' '--enable-sockets' '--enable-wddx' '--disable-xml' '--with-expat-dir=/usr' '--enable-yp' '--with-zlib' '--without-pgsql' '--with-kerberos=/usr' '--with-openssl=/usr' '--with-exec-dir=/usr/lib/php4/libexec' '--disable-static' '--without-mm' '--without-mysql' '--without-sybase-ct'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc/php4/cgi/php.ini
PHP API => 20020918
PHP Extension => 20020429
Zend Extension => 20021010
Debug Build => no
Thread Safety => disabled
Registered PHP Streams => php, http, ftp, https, ftps, compress.bzip2, compress.zlib
This program makes use of the Zend Scripting Language Engine:
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies
__________________________________________________ _____________________
Configuration

PHP Core

Directive => Local Value => Master Value
allow_call_time_pass_reference => On => On
allow_url_fopen => On => On
always_populate_raw_post_data => Off => Off
arg_separator.input => & => &
arg_separator.output => & => &
asp_tags => Off => Off
auto_append_file => no value => no value
auto_prepend_file => no value => no value
browscap => no value => no value
default_charset => no value => no value
default_mimetype => text/html => text/html
define_syslog_variables => Off => Off
disable_classes => no value => no value
disable_functions => no value => no value
display_errors => On => On
display_startup_errors => Off => Off
doc_root => no value => no value
docref_ext => no value => no value
docref_root => no value => no value
enable_dl => On => On
error_append_string => no value => no value
error_log => no value => no value
error_prepend_string => no value => no value
error_reporting => 2039 => 2039
expose_php => On => On
extension_dir => /usr/lib/php4/20020429 => /usr/lib/php4/20020429
file_uploads => On => On
gpc_order => GPC => GPC
highlight.bg => #FFFFFF => #FFFFFF
highlight.comment => #FF8000 => #FF8000
highlight.default => #0000BB => #0000BB
highlight.html => #000000 => #000000
highlight.keyword => #007700 => #007700
highlight.string => #DD0000 => #DD0000
html_errors => On => On
ignore_repeated_errors => Off => Off
ignore_repeated_source => Off => Off
ignore_user_abort => Off => Off
implicit_flush => Off => Off
include_path => .:/usr/share/php:/usr/share/pear => .:/usr/share/php:/usr/share/pear
log_errors => Off => Off
log_errors_max_len => 1024 => 1024
magic_quotes_gpc => On => On
magic_quotes_runtime => Off => Off
magic_quotes_sybase => Off => Off
max_execution_time => 30 => 30
max_input_time => 60 => 60
memory_limit => 8M => 8M
open_basedir => no value => no value
output_buffering => no value => no value
output_handler => no value => no value
post_max_size => 8M => 8M
precision => 12 => 12
register_argc_argv => On => On
register_globals => On => On
report_memleaks => On => On
safe_mode => Off => Off
safe_mode_exec_dir => no value => no value
safe_mode_gid => Off => Off
safe_mode_include_dir => no value => no value
sendmail_from => me@localhost.com => me@localhost.com
sendmail_path => /usr/sbin/sendmail -t -i => /usr/sbin/sendmail -t -i
serialize_precision => 100 => 100
short_open_tag => On => On
SMTP => localhost => localhost
smtp_port => 25 => 25
sql.safe_mode => Off => Off
track_errors => Off => Off
unserialize_callback_func => no value => no value
upload_max_filesize => 2M => 2M
upload_tmp_dir => no value => no value
user_dir => no value => no value
variables_order => EGPCS => EGPCS
xmlrpc_error_number => 0 => 0
xmlrpc_errors => Off => Off
y2k_compliance => On => On

bcmath

BCMath support => enabled

bz2

BZip2 Support => Enabled
BZip2 Version => 1.0.2, 30-Dec-2001

calendar

Calendar support => enabled

ctype

ctype functions => enabled

dba

DBA support => enabled
Supported handlers => cdb cdb_make db4 inifile flatfile

exif

EXIF Support => enabled
EXIF Version => 1.4 $Id: exif.c,v 1.118.2.25 2003/09/22 23:28:07 iliaa Exp $
Supported EXIF Version => 0220
Supported filetypes => JPEG,TIFF

ftp

FTP support => enabled

gettext

GetText Support => enabled

iconv

iconv support => enabled
iconv implementation => glibc
iconv library version => 2.3.2

Directive => Local Value => Master Value
iconv.input_encoding => ISO-8859-1 => ISO-8859-1
iconv.internal_encoding => ISO-8859-1 => ISO-8859-1
iconv.output_encoding => ISO-8859-1 => ISO-8859-1

mbstring

Multibyte Support => enabled
Multibyte (japanese) regex support => enabled

mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1.

Directive => Local Value => Master Value
mbstring.detect_order => no value => no value
mbstring.encoding_translation => Off => Off
mbstring.func_overload => 0 => 0
mbstring.http_input => pass => pass
mbstring.http_output => pass => pass
mbstring.internal_encoding => ISO-8859-1 => no value
mbstring.language => neutral => neutral
mbstring.substitute_character => no value => no value

openssl

OpenSSL support => enabled
OpenSSL Version => OpenSSL 0.9.7d 17 Mar 2004

overload

User-Space Object Overloading Support => enabled

pcre

PCRE (Perl Compatible Regular Expressions) Support => enabled
PCRE Library Version => 4.5 01-December-2003

posix

Revision => $Revision: 1.51.2.2 $

session

Session Support => enabled
Registered save handlers => files user

Directive => Local Value => Master Value
session.auto_start => Off => Off
session.bug_compat_42 => On => On
session.bug_compat_warn => On => On
session.cache_expire => 180 => 180
session.cache_limiter => nocache => nocache
session.cookie_domain => no value => no value
session.cookie_lifetime => 0 => 0
session.cookie_path => / => /
session.cookie_secure => Off => Off
session.entropy_file => no value => no value
session.entropy_length => 0 => 0
session.gc_divisor => 100 => 100
session.gc_maxlifetime => 1440 => 1440
session.gc_probability => 1 => 1
session.name => PHPSESSID => PHPSESSID
session.referer_check => no value => no value
session.save_handler => files => files
session.save_path => /tmp => /tmp
session.serialize_handler => php => php
session.use_cookies => On => On
session.use_only_cookies => Off => Off
session.use_trans_sid => Off => Off

shmop

shmop support => enabled

sockets

Sockets Support => enabled

standard

Regex Library => Bundled library enabled
Dynamic Library Support => enabled
Path to sendmail => /usr/sbin/sendmail -t -i

Directive => Local Value => Master Value
assert.active => 1 => 1
assert.bail => 0 => 0
assert.callback => no value => no value
assert.quiet_eval => 0 => 0
assert.warning => 1 => 1
auto_detect_line_endings => 0 => 0
default_socket_timeout => 60 => 60
safe_mode_allowed_env_vars => PHP_ => PHP_
safe_mode_protected_env_vars => LD_LIBRARY_PATH => LD_LIBRARY_PATH
url_rewriter.tags => a=href,area=href,frame=src,input=src,form=,fieldse t= => a=href,area=href,frame=src,input=src,form=,fieldse t=
user_agent => no value => no value

tokenizer

Tokenizer Support => enabled

wddx

WDDX Support => enabled
WDDX Session Serializer => enabled

xml

XML Support => active
XML Namespace Support => active
EXPAT Version => expat_1.95.6

yp

YP Support => enabled

zlib

ZLib Support => enabled
Compiled Version => 1.2.1
Linked Version => 1.2.1

Directive => Local Value => Master Value
zlib.output_compression => Off => Off
zlib.output_compression_level => -1 => -1
zlib.output_handler => no value => no value

Additional Modules

Module Name
filepro
sysvsem
sysvshm

Environment

Variable => Value
USER => robert
LOGNAME => robert
HOME => /home/robert
PATH => .:/home/robert/bin:/home/robert/bin/linux:/usr/local/lang:/bin:/usr/bin:/usr/ucb:/usr/old:/usr/etc:/etc:/sbin:/usr/sbin:/usr/5bin
SHELL => /usr/bin/tcsh
PLATFORM => linux
TRASHDIR => /home/robert/trash
LD_LIBRARY_PATH => /home/robert/lib/local/darkstar:/home/robert/lib:/home/robert/lib/local:/home/robert/lib/gnu:/home/robert/lib/public
REMOTEHOST =>
TERMINFO => /home/robert/.terminfo
MANPATH => /home/robert/man:/usr/man:/usr/share/man:/home/robert/man/X11:/home/robert/man/cat1:/home/robert/man/index.bt:/home/robert/man/index.db.gz:/home/robert/man/local:/home/robert/man/man1:/home/robert/man/perl:/home/robert/man/whatis
SHLVL => 2
HOSTTYPE => i386-linux
VENDOR => intel
OSTYPE => linux
MACHTYPE => i386
PWD => /home/robert
GROUP => robert
HOST => darkstar

PHP Variables

Variable => Value
PHP_SELF =>
_SERVER["USER"] => robert
_SERVER["LOGNAME"] => robert
_SERVER["HOME"] => /home/robert
_SERVER["PATH"] => .:/home/robert/bin:/home/robert/bin/linux:/usr/local/lang:/bin:/usr/bin:/usr/ucb:/usr/old:/usr/etc:/etc:/sbin:/usr/sbin:/usr/5bin
_SERVER["SHELL"] => /usr/bin/tcsh
_SERVER["PLATFORM"] => linux
_SERVER["TRASHDIR"] => /home/robert/trash
_SERVER["LD_LIBRARY_PATH"] => /home/robert/lib/local/darkstar:/home/robert/lib:/home/robert/lib/local:/home/robert/lib/gnu:/home/robert/lib/public
_SERVER["REMOTEHOST"] =>
_SERVER["TERMINFO"] => /home/robert/.terminfo
_SERVER["MANPATH"] => /home/robert/man:/usr/man:/usr/share/man:/home/robert/man/X11:/home/robert/man/cat1:/home/robert/man/index.bt:/home/robert/man/index.db.gz:/home/robert/man/local:/home/robert/man/man1:/home/robert/man/perl:/home/robert/man/whatis
_SERVER["SHLVL"] => 2
_SERVER["HOSTTYPE"] => i386-linux
_SERVER["VENDOR"] => intel
_SERVER["OSTYPE"] => linux
_SERVER["MACHTYPE"] => i386
_SERVER["PWD"] => /home/robert
_SERVER["GROUP"] => robert
_SERVER["HOST"] => darkstar
_SERVER["PHP_SELF"] =>
_SERVER["SCRIPT_NAME"] =>
_SERVER["SCRIPT_FILENAME"] =>
_SERVER["PATH_TRANSLATED"] =>
_SERVER["DOCUMENT_ROOT"] =>
_SERVER["argv"] => Array
(
)

_SERVER["argc"] => 0
_ENV["USER"] => robert
_ENV["LOGNAME"] => robert
_ENV["HOME"] => /home/robert
_ENV["PATH"] => /usr/barra/frame3.1/bin:.:/home/robert/bin:/home/robert/bin/linux:/usr/local/lang:/usr/atria/bin:/disks/lazarus/home/sybase:/usr/lang:/bin:/usr/bin:/usr/ucb:/usr/old:/usr/etc:/etc:/sbin:/usr/sbin:/net/t_rex/disk2/arms/import/gnu/bin:/usr/5bin
_ENV["SHELL"] => /usr/bin/tcsh
_ENV["PLATFORM"] => linux
_ENV["TRASHDIR"] => /home/robert/trash
_ENV["LD_LIBRARY_PATH"] => /home/robert/lib/local/darkstar:/home/robert/lib:/home/robert/lib/local:/home/robert/lib/gnu:/home/robert/lib/public
_ENV["REMOTEHOST"] =>
_ENV["TERMINFO"] => /home/robert/.terminfo
_ENV["MANPATH"] => /home/robert/man:/usr/man:/usr/share/man:/home/robert/man/X11:/home/robert/man/cat1:/home/robert/man/index.bt:/home/robert/man/index.db.gz:/home/robert/man/local:/home/robert/man/man1:/home/robert/man/perl:/home/robert/man/whatis
_ENV["SHLVL"] => 2
_ENV["HOSTTYPE"] => i386-linux
_ENV["VENDOR"] => intel
_ENV["OSTYPE"] => linux
_ENV["MACHTYPE"] => i386
_ENV["PWD"] => /home/robert
_ENV["GROUP"] => robert
_ENV["HOST"] => darkstar

PHP License
This program is free software; you can redistribute it and/or modify
it under the terms of the PHP License as published by the PHP Group
and included in the distribution in the file: LICENSE

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

If you did not receive a copy of the PHP license, or have any
questions about PHP licensing, please contact li*****@php.net.


Jul 17 '05 #1
2 6039
With total disregard for any kind of safety measures
pz*******@sneakemail.com (Robert) leapt forth and uttered:

I am using the php4-cgi Debian package which is based on PHP
4.3.4.

I have problems when running php4 on the command line. If I say
something like

$ php4 index.cgi

a number of variables are not initialized. For example,
$HTTP_GET_VARS is not set. To get it set, here's my workaround:


To read command line arguments use $_SERVER['argc'] (to get the
argument count) and $_SERVER['argv'] (to get an array of passed
arguments)

--
Phil Roberts | Dork Pretending To Be Hard | http://www.flatnet.net/
Jul 17 '05 #2
Parsing arguments is indeed useful, but I'm curious as to why

$ php4 index.cgi

with REQUEST_METHOD (=POST) and CONTENT_LENGTH environment variables does
not read the body of the CGI request. Perhaps if I can get to that point,
I can figure out why $HTTP_POST_VARS (or $GLOBALS['HTTP_POST_VARS']) is
not getting set.

Thanks.
From: Phil Roberts <ph*****@HOLYflatnetSHIT.net>
Date: Mon, 05 Apr 2004 02:28:37 -0500

With total disregard for any kind of safety measures
pz*******@sneakemail.com (Robert) leapt forth and uttered:
I am using the php4-cgi Debian package which is based on PHP
4.3.4.

I have problems when running php4 on the command line. If I say
something like

$ php4 index.cgi

a number of variables are not initialized. For example,
$HTTP_GET_VARS is not set. To get it set, here's my workaround:


To read command line arguments use $_SERVER['argc'] (to get the
argument count) and $_SERVER['argv'] (to get an array of passed
arguments)

--
Phil Roberts | Dork Pretending To Be Hard | http://www.flatnet.net/


Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hal Vaughan | last post by:
I have a script used to find and run Java on a Windows system.Itworked fine on original tests (on a Windows XP system).It'snowrunningona Windows 2000 (sp3) system, and it won't work -- the...
15
by: Thomas Scheiderich | last post by:
I am trying to understand Session variables and ran into a question on how they work with data that is passed. I have an HTM file that calls an ASP file and sends the name either by GET or POST....
12
by: Rhino | last post by:
I am having an odd problem: the sqlj command on my system doesn't work. I am running DB2 (LUW) V8 (FP8) on WinXP. I haven't done an sqlj program since Version 6 of DB2 (LUW) so I checked the...
3
by: brix_zx2 | last post by:
I have an Excel Spreadsheet I want to import the records (5 fields) into an access 2000 DB. Went on the net looking and found stuff for SQL (which I don't know a thing about) and now I'm confused....
24
by: moriman | last post by:
Hi, The script below *used* to work. I have only just set up a server, PHP etc again on my Win98 system and now it doesn't? On first loading this page, you would have $p = and the button...
11
by: livin | last post by:
I need to post form data to an ASP page that looks like this on the page itself... <form method='POST'><input src=\icons\devices\coffee-on.gif type='image' align='absmiddle' width=16 height=16...
12
by: arenium | last post by:
Hi, I'll cut to the chase. I have a class named Foo(). I create an instance of this class named bar, and I set bar.data to a large list of tuples. Within Foo() there is a method which...
1
by: amphibian1 | last post by:
Hello, I am writing a C# command line application that uploads files to a website. Basically, imagine this form in a web application: <form method="post" enctype="mulipart/form-data"...
4
by: lilyumestar | last post by:
I have project I have to do for class. We have to write 4 different .java files. Project2.java HouseGUI.java House.java HouseSorting.java I already finish House.java and I need to work on...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.