PHP中的FreeTDS错误:传入的表格数据流(TDS)远程过程调用(RPC)协议流不正确

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了PHP中的FreeTDS错误:传入的表格数据流(TDS)远程过程调用(RPC)协议流不正确脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我必须使用ODBC从Arch Linux连接到MSsql服务器.
我使用FreeTDS,而使用isql,它正在工作:

isql sqlexPress dev Dev

但不是在PHP中.
我在交互模式下使用PHP

PHP > $conn = odbc_connect("sqlexPRess",'dev','Dev');
PHP > $a=odbc_exec($conn,'SELECT * From measures;');
PHP Warning:  odbc_exec(): sql error: [FreeTDS][sql Server]The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 (""): Data tyPE 0x00 is unkNown.,sql state 37000 in sqlExecDirect in PHP shell code on line 1

Warning: odbc_exec(): sql error: [FreeTDS][sql Server]The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 (""): Data type 0x00 is unkNown.,sql state 37000 in sqlExecDirect in PHP shell code on line 1

搜索了很多,但我找不到任何解决方案(甚至是有同样问题的人).
我的配置文件

/etc/odbc.ini:

[sqlexpress] 
Server = 192.168.10.39
Port = 1433
Driver = FreeTDS
Database = capture
UserName = dev
Password = Dev

/etc/odbcinst.ini:

[FreeTDS]
Description = FreeTDS driver
Driver = /usr/lib/liBTdsodbc.so
SETUP = /usr/lib/libtdsS.so
Trace = Yes
TraceFile = /tmp/freetds.LOG
Fileusage = 1
UsageCount = 1

祝你今天愉快!
伴侣

解决方法

这是我从ubuntu连接到MSsql数据库的工作配置文件

/etc/odbc.ini

# define a connection to the MSsql server.
# The Description can be whatever we want IT to be.
# The Driver value must match what we have defined in /etc/odbcinst.ini
# The Database name must be the name of the database this connection will connect to.
# The ServerName is the name we defined in /etc/freetds/freetds.conf
# The TDS_Version should match what we defined in /etc/freetds/freetds.conf
[ebe]
Description             = MSsql Server
Driver                  = freetds
Database                = my_database
ServerName              = my_server_name
TDS_Version             = 8.0

/etc/odbcinst.ini

# Define where to find the driver for the Free TDS connections.
[freetds]
Description     = MS sql database access with Free TDS
Driver          = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup           = /usr/lib/i386-linux-gnu/odbc/libtdsS.so
UsageCount      = 1

# Change the "no" to "yes" to enable ODBC logging.
[ODBC]
Trace           = no
TraceFile       = /tmp/odbc.log

/etc/freetds/freetds.conf

[global]
        # If you get out-of-memory errors,it may mean that your client
        # is trying to allocate a huge buffer for a TEXT field.  
        # Try setting 'text size' to a more reasonable limit 
        text size = 64512

# Define a connection to the MSsql server.
[my_server_name]
    host = my_server_domain_or_ip
    port = 1433
    tds version = 8.0

最后,这是我的PHP连接字符串:

$this->db_connection = new PDO("dblib:dbname=my_database;host=my_server_domain_or_ip",'username','password');

我相信将tds版本设置为8.0可能对您有很大帮助.

脚本宝典总结

以上是脚本宝典为你收集整理的PHP中的FreeTDS错误:传入的表格数据流(TDS)远程过程调用(RPC)协议流不正确全部内容,希望文章能够帮你解决PHP中的FreeTDS错误:传入的表格数据流(TDS)远程过程调用(RPC)协议流不正确所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。