Skip to Content.
Sympa Menu

freetds - Re: via PHP to Microsoft SQL Server V7.0

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Bruns <camber AT umcc.ais.org>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: via PHP to Microsoft SQL Server V7.0
  • Date: Mon, 17 Jan 2000 19:09:53 -0500 (EST)




On Mon, 17 Jan 2000, James Cameron wrote:

> I'm struggling to get php working with freetds to query a Microsoft SQL
> Server ... has anyone done this recently? Is it doable? Can anyone
> point at example php scripts?
>
Here is an example I'm pulling out of the archives, but it should suffice
(error checking has been stripped out)

$cnn = sybase_pconnect("Your MS SQL Server","Login","Password")
$db = sybase_select_db("A Database",$cnn)
$sql = "SELECT ID, Surname FROM Customer WHERE ID = 10000696";
echo "$sql<BR>";
$qry = sybase_query($sql);
if($qry){
list($i1,$i2) = sybase_fetch_row($qry);
echo "$i1 $i2<BR>\n";
}
sybase_free_result($qry);

> Problem: when running php against a script that tries to connect to the
> database, an strace shows that a name server lookup is made for a host
> "\0ctual", a null length string. The host set in the call was "actual";
> the first letter is overwritten. The null host is not resolved and so
> the sybase_connect() call fails.
>
> When running it within gdb, however, the host name is not corrupted and
> the connection request is sent out on the 'net.
>

Can you provide a bit more info about your environment...What your $SYBASE
var is set to, a copy of the interfaces file entry, etc... also does it
run ok when using an IP address instead of a hostname?

Brian
> If the network is disconnected, and the php script is run without gdb,
> it pauses on the name server lookup. Activating gdb against the running
> process (gdb `which php` $pid) shows the host name is again corrupt.
>
> It appears the change to the host name is occuring within freetds's
> dblib/dblic.c code.
>
> Configuration: Red Hat V5.2, php-3.0.14, freetds-0.50.
>
> --
> James Cameron (cameron AT stl.dec.com)
>
> http://www.opensource.org/ http://vanilla.us.netrek.org/ http://lwn.net/






Archive powered by MHonArc 2.6.24.

Top of Page