Click to See Complete Forum and Search --> : win2k/4.2.2 constant/variable problems
ibert
08-28-2002, 07:06 AM
I´ve installed php 4.2.2. already edited the php.ini for register_globals (due the problem of self), but I still have troubles:
Notice: Use of undefined constant xxx - assumed in yyy.php
mysql_fetch_row(): supplied argument is not a valid MySQL result resource
Notice: Undefined offset:
and so on...
Any idea?
Has anyone solved this problem?
malbera
08-28-2002, 07:15 AM
can you post some code?it will help us to solve your problem.
ibert
08-28-2002, 07:19 AM
It occurs on tested codes like phpnuke or contentbuilder. I guess mainly when communicating with mysql db.
for me it seems like a general config problem inside php.ini...
philipolson
10-14-2002, 02:56 AM
Undefined constant is an error of level E_NOTICE, this can be set either by the error_reporting (http://www.php.net/error_reporting) function or directive. It's a undefined constant because PHP first looks for a constant named foo, if it isn't found it'll throw the E_NOTICE error and then look for an array key named 'foo'. Example:
print $array[foo]; // undefined constant (most likely)
print $array['foo']; // do this instead
print "this is okay $array[foo] though"; // because constants aren't looked for in strings
define('a','b'); // define a constant a with the value b
$arr = array('a' => 'apple', 'b' => 'banana');
print $arr[a]; // banana
print $arr['a']; // apple
Not a valid resource is a little tougher to spot but with a little debugging it can be solved. The function mysql_error (http://www.php.net/mysql_error)() can be very useful for this. An example:
if (!$result = @mysql_query($sql)) {
print "Invalid result, could not run query ($sql) : " . mysql_error();
exit;
}
The basic idea is that mysql_query (http://www.php.net/mysql_query)() returns boolean false on failure and mysql_error() will tell you the problem. Maybe there isn't a database connection, or no selected database? If so, that might explain the undefined offset too.
PHP Builder
Copyright Internet.com Inc. All Rights Reserved.