dqc3469 2019-01-08 10:29
浏览 372
已采纳

我需要将SQL SERVER连接到我的codeigniter项目

No it's not a Duplicate. In that also they said to include dll files. I did it but still I got same error

I need to connect sql server to codeigniter project. And I added

extension = php_sqlsrv_56_ts.dll in php.ini

But still I got fatal Error.

$db['default'] = array(
    'dsn'   => '',
    'hostname' => 'ADMIN-PC\SQLEXPRESS',
    'username' => 'name',
    'password' => 'password',
    'database' => 'dbname',
    'dbdriver' => 'sqlsrv',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);

This is what I got while run this on localhost (Appache Server)

Fatal error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs\MyProject\system\database\drivers\sqlsrv\sqlsrv_driver.php on line 144

A PHP Error was encountered Severity: Error

Message: Call to undefined function sqlsrv_connect()

Filename: sqlsrv/sqlsrv_driver.php

Line Number: 144

Backtrace:

  • 写回答

1条回答 默认 最新

  • dsdtszi0520538 2019-01-22 09:54
    关注

    After many attempts I finally find solution.

    All you need to follow below steps.

    Step 1: Find version of your php by using php_info().

    Step 2 : You have to find exact sqlsrv compiler (which means the .dll file) for your php version.

    Eg : if you are using php 7.1 then the exact compiler is php_sqlsrv_71_ts.dll
    like if you using php 5.6 then it should be php_sqlsrv_56_ts.dll

    Step 3 : Add this in your xampp/php/ext folder

    Step 4 : Then add this line in your php.ini file extension=php_sqlsrv_71_ts_.dll

    Step 5 : Now stop and start Apache server.

    Now You can find sqlsrv in php_info().

    if you didn't find then you should check error log.

    That's all Thank you folks :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题