Re: Subject: No prob with a module
| From: | Neil Smith | Date: | Tue, 22 Apr 2003 10:47:23 +0000 |
| Subject: | Re: Subject: No prob with a module | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-19546@lists.php.net to get a copy of this message | ||
Problem with module? Possibly not.
Have you actually *defined* the global variable $GLOBALS["db_type"] ? What is it set to ?
According to your script this will only execute line 168 when this value is set to ODBC, yet you say you are using mysql. In that case, use and set this value to mysql - the script will use the (more efficient) native PHP handlers for mysql rather than the slower more generic ODBC ones you are specifying.
Incidentally, its probably down to you ahve not uncommented the odbc line in your php.ini,wheras if you ran phpinfo() on both your and the ISP machines you would see theirs *have* ODBC support compiled in, wheras yours doesn't. One to watch out for.
Also oddly (and pointlessly) there are two 'return' statements inside each if : yet, the script can only ever execute *one* of them (can only return *once* from a function !!). There are probably other bugs in the script too, but I couldn't be bothered to find them. DB Abstraction classes are all over the place - why not go to www.phpbuilder.com and find a few - save yourself reinventing the wheel?
Cheers,
Neil Smith.
At 09:58 22/04/2003 +0000, Alan wrote:
Subject: A prob with a module maybe?? I have a script that runs clean on a Linux already configured system (my hosting provider) and I tried to ran the same script on my local machine. I get errors, which I belive are due to a missing module of some sort. I just don't know which module. Fatal error: Only variables can be passed by reference in c:\localhost\treeview\Config\php-dbi.inc.php on line 168 // Retrieve a single row from the database and return it // as an array. // Note: we don't use the more useful xxx_fetch_array because not all // databases support this function. 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"]++ ); if ( ! $r ) { die("Unable to fetch row"); return ''; } } else { $r = ''; } return $r; } else if ( strcmp ( $GLOBALS["db_type"], "odbc" ) == 0 ) { $num_fields = odbc_num_fields ( $res ); if ( ! odbc_fetch_into ( $res, $GLOBALS["odbc_row"]++, &$ret ) ) // THIS IS LINE 168 WHERE ERROR IS return false; return $ret; } else { dbi_fatal_error ( "dbi_fetch_row(): db_type not defined." ); } } The script in question has been (and still is) running perfect on Linux system (two separate systems). The install on WinXP is the one failing. My take on this is that something is not enabled just right and therefore it is unable to process it as it does on the Linux systems. Any suggestions on what I need to enable? (i.e. any modules that need to be loaded up?). This is a call to a database (mySql). PHP Version 4.3.1 MySQL 3.23.49 Apache/1.3.27 (Win32) WinXP Pro P4 1.5Ghz 256MB RAM -Alon. js@wsco.com