Page 1 of 1
Newbie: Undefined index: ..= $HTTP_POST_VARS["hook"
Posted: Mon Jun 19, 2006 6:56 am
by fopetesl
I am at something of a loss as to how to dig this one out. The same php script on a Mandrake 10 machine runs fine but on the Ubuntu machine I get the error/warning:
Code: Select all
Notice: Undefined index: hook in /var/www/html/processData.php on line 9
8
9
$hook = $HTTP_POST_VARS["hook"];
10
if(isset($parameter0)) $parameter0 = $HTTP_POST_VARS["parameter0"];
The actual script begins:
Code: Select all
<?php
include "debugHelper.php";
// Updated: 28/03/2006 @ 14:45
// ACQUIRE FLASH VARIABLES HERE AND TURN THEM INTO PHP VARIABLES
$hook = $HTTP_POST_VARS["hook"];
if(isset($parameter0)) $parameter0 = $HTTP_POST_VARS["parameter0"];
if(isset($parameter1)) $parameter1 = $HTTP_POST_VARS["parameter1"];
I obviously do not have a global? variable set somewhere.
BTW this script is meant to be called from a Flash GUI but when I attempt to run the GUI it fails without any traceable error. (It runs fine on MDK10) Are the trwo problems connected or is it merely a PHP problem?
Posted: Mon Jun 19, 2006 8:20 am
by JayBird
This is becuase on this installation, error reporting is set to a higher level.
Basically, to rectify the problem your code code look something like this
Code: Select all
if(isset($HTTP_POST_VARS["hook"]))
{
$hook = $HTTP_POST_VARS["hook"];
}
else
{
echo "hook is not set";
}
Yo! That one's cured but ...
Posted: Mon Jun 19, 2006 9:15 am
by fopetesl
I now have a problem in loading the GUI and running MySql query.
Cured the above by 'calling' the php script from the GUI. That undefined variable appears to be supplied by the GUI(?).
Am checking MySql permissions .. more later TY pimp'
Posted: Mon Jun 19, 2006 9:56 am
by yamobe
another way to make it work is to replace $HTTP_POST_VARS by $_POST.
Posted: Mon Jun 19, 2006 10:14 am
by JayBird
yamobe wrote:another way to make it work is to replace $HTTP_POST_VARS by $_POST.
That wouldn't solve the first Notice.
One step further ...
Posted: Tue Jun 20, 2006 9:21 am
by fopetesl
Now attempting to run script from GUI i get:
and when I look in apache/error.log:
Code: Select all
[Tue Jun 20 16:05:51 2006] [error] [client 127.0.0.1] script '/var/www/processData.php' not found or unable to stat, referer: http://127.0.0.1/html/gui.swf
Please note:
processData.php is actually in
/var/www/html/ directory together with
gui.swf,
not in
/var/www/ directory. These proggies run just fine on an older Mandrake10 machine from the
/../html/ directory.
Somewhere I do not have a path set correctly but after hours of searching I cannot discover just where.
Posted: Tue Jun 20, 2006 9:59 am
by Luke
Posted: Tue Jun 20, 2006 10:24 am
by fopetesl
Ummm. Include in what? Write another php script in ../html/ ?
Re: Newbie: Undefined index: ..= $HTTP_POST_VARS["hook&
Posted: Tue Jun 20, 2006 10:33 am
by Luke
Code: Select all
<?php
include "html/debugHelper.php"; // Right here
// Updated: 28/03/2006 @ 14:45
// ACQUIRE FLASH VARIABLES HERE AND TURN THEM INTO PHP VARIABLES
$hook = $HTTP_POST_VARS["hook"];
if(isset($parameter0)) $parameter0 = $HTTP_POST_VARS["parameter0"];
if(isset($parameter1)) $parameter1 = $HTTP_POST_VARS["parameter1"];
Posted: Tue Jun 20, 2006 10:59 am
by fopetesl
OK. Call me a thicko then but if apache/localhost/gui.swf cannot find ProCessData.php in the ../html/ directory how is it/them going to catch the "include" statement? Note there are no errors regarding debugHelper.php .. Yet.
Posted: Tue Jun 20, 2006 5:34 pm
by Robert Plank
To take care of the undefined index notice you should be checking for array_key_exists before using an array subscript.
Like:
Code: Select all
if (array_key_exists("hook", $_POST)) {
$hook = $_POST["hook"];
}