Skip to Content.
Sympa Menu

freetds - Re: Freetds + Unixodbc + PHP

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "J. 'FIK' Brand" <jurgen.brand AT tip.nl>
  • To: "TDS Development Group" <freetds AT franklin.oit.unc.edu>
  • Subject: Re: Freetds + Unixodbc + PHP
  • Date: Tue, 4 Dec 2001 12:19:14 +0100


It's the SQL statment.

Select statments that work in isql (unixODBC utilitie) don't work in PHP.

simple statments work (see example 1), but when i change the first sql
statment (see example 2) is doesn't work anymore. The same statment works in
isql.

example 1 :

<?php
putenv("ODBCINI=/opt/unixODBC/etc/odbc.ini");
putenv("ODBCINSTINI=/opt/unixODBC/etc/odbcinst.ini");
putenv("LD_LIBRARY_PATH=/opt/unixODBC/lib");

$Conn= odbc_connect ("doc1","www","www")
or die ("Can't open ODBC-DSN");
$Rec = odbc_exec ( $Conn, "select * from book")
or die ("Can't execute QUERY");

echo "Records returnd : ".odbc_num_rows($Rec)."<br>\n";
while (odbc_fetch_row ($Rec))
{
echo odbc_field_name ($Rec,1)." - ";
echo odbc_result($Rec,1);
echo " | ";
echo odbc_field_name ($Rec,2)." - ";
echo odbc_result($Rec,"bk_title");
echo "<br>\n";
}

$Rec = odbc_exec ( $Conn, "select pg_title from pages")
or die ("Can't execute QUERY");
echo odbc_field_name ($Rec,1)." - ";
echo odbc_result($Rec,1);
echo "<br>\n";
?>

example 2 :

$Rec = odbc_exec ( $Conn, "select count(bk_id) from book")
or die ("Can't execute QUERY");

----- Original Message -----
From: "Brian Bruns" <camber AT ais.org>
To: "TDS Development Group" <freetds AT franklin.oit.unc.edu>
Sent: Tuesday, December 04, 2001 12:48 AM
Subject: [freetds] Re: Freetds + Unixodbc + PHP


>
> Ok thanks, I think I should be able to track it down from here, although
> I'm a bit squeezed for time tonight. A work around may be to structure
> the code more traditionally like:
>
> $res = odbc_exec($conn, "select * from table1");
>
> while (odbc_fetch_row($res)) {
> echo odbc_result($res,"col1");
> echo odbc_result($res,2);
> }
>
> Note: I'm typing it from memory but that should be the jist of it. This
> should ensure that the first result set is closed out. By the way, if you
> compile php in cgi mode and run it with TDSDUMP set, you may see something
> like 'Attempt to initiate a new query with results pending.' to make sure
> the error is what I think it is.
>
> Brian
>
> On Mon, 3 Dec 2001, J. 'FIK' Brand wrote:
>
> > This is the php script i use :
> >
> > $conn = odbc_connect ("doc","unixodbc","")
> > or die ("can't open connnection");
> > $res = odbc_exec ($conn, "select * from book")
> > or die ("can't execut query");
> > echo odbc_result($res,"bk_id");
> > echo odbc_result($res,2);
> >
> > $res = odbc_exec ($conn, "select * from pages")
> > or die ("can't execut query");
> > echo odbc_result($res,"pg_id");
> > echo odbc_result($res,2);
> >
> > Like this is doesn't work, when i delete the last 4 line it works.
> >
> > Jurgen
> >
> >
> > ----- Original Message -----
> > From: "Brian Bruns" <camber AT ais.org>
> > To: "TDS Development Group" <freetds AT franklin.oit.unc.edu>
> > Sent: Monday, December 03, 2001 8:36 PM
> > Subject: [freetds] Re: Freetds + Unixodbc + PHP
> >
> >
> > >
> > > Can you send an example script of the the problem?
> > >
> > > thanks,
> > >
> > > Brian
> > >
> > > On Mon, 3 Dec 2001, J. 'FIK' Brand wrote:
> > >
> > > > Hello,
> > > >
> > > > My config :
> > > >
> > > > NT Server
> > > > - NT 4.5 (SP6)
> > > > - SQL server 7.0
> > > >
> > > > Linux server
> > > > - redhat 6.2
> > > > - unxiODBC 2.1.0
> > > > - freetds (current snapshot)
> > > > - PHP 4.0.6
> > > >
> > > > My problem :
> > > >
> > > > I can open a connection and execute a SQL statment, but when i try
to
> > run a second statment on the same connection the page become's
unloadable.
> > > >
> > > > In isql (command utilitie from unixodbc) i can execute as many
statments
> > as i want and all work.
> > > >
> > > > Thanks
> > > >
> > > > Jurgen Brand
> > > >
> > > >
> > > >
> > >
> > >
> > > ---
> > > You are currently subscribed to freetds as: [jurgen.brand AT tip.nl]
> > > To unsubscribe, forward this message to
> > $subst('Email.Unsub')
> > >
> >
> >
> > ---
> > You are currently subscribed to freetds as: [camber AT ais.org]
> > To unsubscribe, forward this message to
$subst('Email.Unsub')
> >
>
>
> ---
> You are currently subscribed to freetds as: [jurgen.brand AT tip.nl]
> To unsubscribe, forward this message to
$subst('Email.Unsub')
>





Archive powered by MHonArc 2.6.24.

Top of Page