Skip to Content.
Sympa Menu

freetds - Re: [freetds] tsql works but php does not?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Frank M. Kromann" <frank AT kromann.info>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Cc: <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] tsql works but php does not?
  • Date: Fri, 18 Nov 2005 19:27:30 -0800

The included script does not retreive any data.

$query_result will have a handle to the query (on success) and should be
used as a parameter to mssql_fetch_row() or one of the other fetch
functions to retreive the data.

example:

<?php

$con = mssql_connect($server, $user, $pass);
if ($con) {
mssql_select_db($database, $con);

$rs = mssql_query(*select * from mytable", $con);
if (is_resource($rs)) {
while ($row = mssql_fetch_row($rs)) {
print_r($row);
}
}
}

mssql_close($con);

?>

- Frank

> Hello,
>
> Freetds-0.63 installed. TSQL can connect to the MS SQL server and pull
> the data out fine. But the following php script returns nothing either
on
> command link or in web browser. No error messages even. What am I
> missing? Thanks in advance for any help.
>
> ==
> <?php
>
> // connect to database server
> $db_conn = mssql_connect("MyServer2k","user","pass")
> or die( "<strong>ERROR: Connection to mssql failed</strong>" );
>
> // select database - only if we want to query another database than
the
> default one
> mssql_select_db( "somedb", $db_conn )
> or die( "<strong>ERROR: Selecting database failed</strong>" );
>
> // query the database
> $query_result = mssql_query( "SELECT * FROM somedb", $db_conn )
> or die( "<strong>ERROR: Query failed</strong>" );
>
> /*
> * You can now access the result data by using the appropriate
> mssql_xxx() functions
> * on $query_result. See the PHP manual section on Microsoft SQL
Server
> functions
> * for documentation on how to do this.
> */
>
> mssql_free_result( $query_result ); // unnecessary in PHP 4
>
> mssql_close( $db_conn ); // unnecessary in PHP 4
> ?>
> ==
>
> /usr/local/etc/freetds.conf
>
> ==
> ...
> [MyServer2k]
>
> host = mssql.some.edu
> port = 1433
> tds version = 8.0
> dump file = /tmp/freetds.log
> dump file append = yes
> ...
> ==
>
> Bing
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>







Archive powered by MHonArc 2.6.24.

Top of Page