PHP won't return any records

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Everyone,

I have never used the PHP mssql functions before, I am versed in MySql instead, I cannot get the following code to return any records.

The variables $dbserver, $dbuser, $dbpasswd are defined in a config file and are being read and the connection is being made because I can change any one of the variables to a incorrect value and mssql_connect fails.

When I use TDS Version 8.0 I get back the Resource ID # only.

<?php

$linkID = mssql_connect($dbserver, $dbuser, $dbpasswd);

if(!$linkID)
{
    die('There was an error while attempting to connect to the MSSQL Server');
}

if(!$linkID || !mssql_select_db($database, $linkID))
{
    die('Unable to connect or select database!');
}

//The following is for debugging
$query = "SELECT * FROM pohdr WHERE ponum = '136025'";
echo $query;

print "<BR>";
print "<BR>";

$data = mssql_query($query, $linkID) or die ('Query failed: '.$query);
$result = array();

echo $data;

do {
        while ($row = mssql_fetch_row($data)){
                $result[] = $row;
        }
}while ( mssql_next_result($data) );

// Clean up
mssql_free_result($data);
mssql_close($linkID);

include ('common/footer.php');
?>

My environment:

Server #1 - 100% CentOS RPM installed
CentOS 5.3
Apache 2.2.3
PHP 5.1.6
FreeTDS 0.64

Server #2
Microsoft Server 2003 Enterprise Edition
SQL Server 2005
SQL Server 2000 Compatibility Tools installed

Server #3 - Compiled from Source
CentOS 5.3
Apache 2.2.11
PHP 5.2.10 (also tried 5.2.5, 5.1.6 and 4.4.7)
FreeTDS 0.82

By setting the TDS Version to 8.0 on either Server #1 or Server #2 I can make a connection to the SQL Server using tsql -S {servername} -U {username} and execute the SQL Query above and the records are returned.

If I set the TDS Version to 9.0 I can make a connection to the SQL server but from 0.64 or 0.82 I get this error "Msg 4004, Level 16, State 1, Server {servername}, Line 1 Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier." when I use the SQL Query above.


Any assistance would be greatly appreciated.

Best,

Steve

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux