Re: Subject: No prob with a module

From: Date: Wed, 23 Apr 2003 19:13:06 +0000
Subject: Re: Subject: No prob with a module
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-19580@lists.php.net to get a copy of this message
Hi Neil, This code is part of a program I took and this script was actually written not by me. I d/l it from phpbuilder.net as part of a whole package. So you are correct, there is no need to re-invent the wheel,.. but this one just didn't want to do it's thing. Now the code itself works fine on the linux machine. It is a live code that I just wanted to have locally so that I can play with it a bit. It was d/l straight as-is, and I've never took a look at it before as it was just an include file that took care of the backend processing for accessing the database calls. On the server I have a different php build. The gloabal variable is set to "mysql" value, so it really puzzles me why is it that it doesn't just stop there and instead it goes to the odbc section. I made a decision not to explore it beyond too much and get stuck in anyalysis paralysis and just cut the code and now it handles only mysql and it works fine. If in the future I'll make any changes to the database type to oracle or another, I'll tackle this one again. till then, I want to get my program to run. So far it runs fine now, after I cut out the option to do handle other databases. Thanks for your help, -Alon. "Neil Smith" <neil@fresh-toast.uklinux.net> ??? ??????:5.2.0.9.0.20030422113955.00a8a1f0@mail.uklinux.net... > 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 >

« previous php.windows (#19580) next »