Log in

View Full Version : Mystery Function - say what?



kuau
05-09-2008, 09:10 PM
I just moved a domain to a new host and the existing code is having some problems on the new server, probably due to newer versions of MySQL and php. I know minimal php, only what I learned trying to do css.

This function is causing a warning message in the error log:


function dbi_fetch_row ( $res ) {
if ( strcmp ( $GLOBALS["db_type"], "mysql" ) == 0 ) {
return mysql_fetch_array ( $res );
} else if ( strcmp ( $GLOBALS["db_type"], "oracle" ) == 0 ) {
if ( OCIFetchInto ( $GLOBALS["oracle_statement"], &$row,
OCI_NUM + OCI_RETURN_NULLS ) )
return $row;
return 0;
} else if ( strcmp ( $GLOBALS["db_type"], "postgresql" ) == 0 ) {
if ( $GLOBALS["postgresql_numrows"] > $GLOBALS["postgresql_row"] ) {
$r = pg_fetch_array ( $res, $GLOBALS["postgresql_row"] );
$GLOBALS["postgresql_row"]++;
if ( ! $r ) {
echo "Unable to fetch row\n";
return '';
}
}
else {
$r = '';
}
return $r;
} else if ( strcmp ( $GLOBALS["db_type"], "odbc" ) == 0 ) {
if ( ! odbc_fetch_into ( $res, $ret ) )
return false;
return $ret;
} else {
dbi_fatal_error ( "dbi_fetch_row(): db_type not defined." );
}
}


Error Log:
PHP Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in /hermes/web03/server/htdocs/php/php-dbi.php on line 151.

I would rather update the code than change the php.ini. I just don't know how. Can someone please push me in the right direction?

Thanks, erin :)

tfit
05-10-2008, 04:33 AM
The problem lies here: &$row. Try using it without &

kuau
05-12-2008, 05:20 PM
Dear tfit:

That was it!! I just deleted the "&" and no more error messages! Yahoo! I have no idea what any of it means, but as long as it works, fine by me.

Thanks a million! Erin :)

shotgun_ninja
05-12-2008, 10:13 PM
Also, changing the PHP.ini file is easy.

Don't let the .ini extension trick you, it's just a text file. Open it in Notepad/(your editor here).

Then, let's say you need to set allow_call_time_pass_reference to true, add this line, towards the top-ish, but not with a #:

allow_call_time_pass_reference = true

Sometimes you have to change your php.ini file, so it's best you learn how now, in case you need the information later.

Other than that, you seem to be a pretty informed PHP coder.

kuau
05-16-2008, 04:03 PM
Dear Shotgun:

Thanks for the compliment but unfortunately it is unearned. I may understand programming logic, but php is a new language for me so I really am illiterate. I am just a fairly good mimmick. I am always nervous about changing something with such far-reaching repercussions as the php.ini file when I don't fully understand what a setting is for (eg. call_time_pass_reference), especially if there is indication that something is deprecated. I would be lost without the people on this forum (understatement). I learn so much here. I really appreciate everyone's willingness to share what they know. Thanks very much. Aloha, erin :)