odbc - strange behaviour on multiple odbc_exec...

From: Date: Mon, 14 Aug 2000 11:27:41 +0000
Subject: odbc - strange behaviour on multiple odbc_exec...
Groups: php.db 
Request: Send a blank email to php-db+get-2036@lists.php.net to get a copy of this message
hi folks, I have another odbc problem - I hope someone can see what I'm doing wrong, because I sure can't! The code makes a connection, and executes two queries. The first works fine - no problem there. The second always gives an error. If I strip out the first completely, just leaving the second, it works ok! Here is the code:-- $id = odbc_pconnect("DSN=crime_no; UID=ingres;PWD=xxx", "", ""); $sql = "select charge_type, search_descrip from CHARGE_CODES" . " where charge_code = '$c' "; $res = odbc_exec($id, $sql); $r = odbc_fetch_row($res); $ctype = odbc_result($r, "charge_type"); $sdesc = odbc_result($r, "search_descrip"); // everyrthing is cool to here - the above sql works perfectly // the next two lines are an attempt to get over my problem $e = odbc_commit( $id); $e = odbc_free_result( $r ); // this following query gives me 'Warning: bad result index 1 in ... for each of // the odbc_result calls. $sql = "select seq_no, charge_text from CHARGE_STYLES " . " where charge_code = '$c' order by seq_no"; $res = odbc_exec($id, $sql); while ( $r = odbc_fetch_row($res)) { $seq = odbc_result($r, "seq_no"); $txt = odbc_result($r, "charge_text"); echo "<P>$txt\n"; }; One interesting thing is that, before I put in the odbc_free_result, I used to get an error saying there was no variable "seq_no", and "charge_text" in these last two odbc_result calls. BUT, if I changed "charge_text" to read "charge_type" (ie, a column in the *first* odbc_exec), then that is found!! It's like as if the odbc result stuff is not clearing ; it's still got stuff from the previous query - hence my attempt at odbc_free_result... any thoughts please? many thanks again (Linux RH 6.1; Openlink ;, PHP 3; apache....) Gordon Gallacher Inverness, Scotland

« previous php.db (#2036) next »