Re: how do i establish odbc connection?

From: Date: Wed, 10 Jul 2002 20:39:00 +0000
Subject: Re: how do i establish odbc connection?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-20483@lists.php.net to get a copy of this message
hey gabor you have to define a DNS on your system. i assume that you know what DNS is and how to create on windows. if not, say it! afterwards check, if the odbc has been activated in your php.ini on windows-directory! the rest is easy: the code looks like that: if( !$con=odbc_connect($dns,$user,$pwd) ) exit; // establish connection, if faild exit $qry = "SELECT * FROM $table"; // generate the query $res=odbc_exec($con,$qry); // execute query and get result $fieldscnt = odbc_num_fields($res); // count fields while( $n = odbc_fetch_into($res,&$arr) ) // loop as long as it has records and fetch data into array { for( $i=0; $i<$fieldscnt; $i++) // loop all fields echo $arr[$i]"; // display value in array on current field-element $i } if($res) odbc_free_result($res); // free memory of result if there's a result if($con) odbc_close($con); // free connection if there's an established connection as you can see, only a few lines... cheers, j.a.z. "Gabor Niederlaender" <gabor.niederlaender@wu-wien.ac.at> schrieb im Newsbeitrag news:200207091345.PAA27498@isis.wu-wien.ac.at... > Hi all! > > I realized, that it is impossible to retrieve "ntext" from an MSSQL DB > with php normally. (Is this correct?) > > But I think it should be possible to make it through ODBC. > Can someone explain me how this goes? (I think I have set up one ODBC > Data Source, but I am not sure) But I cannot even imagine how I use > this stuff for establishing a connection... > > Does it really only go this way? > > Best regards, > Gabor

« previous php.db (#20483) next »