473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 6100
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.  It worked fine on original tests (on a Windows XP system).  It's now running on a 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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.