arning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序, SQL state IM002 in SQLConnect in D:\webcome\renrenup.com\newfile.php on line 18

解决方案 »

  1.   

    $myServer = localhost; //主机  
    $myUser = wyz_newgou; //用户名  
    $myPass = wyz_168168; //密码  
    $myDB = netsales; //MSSQL库名  
    $s = @mssql_connect($myServer,$myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer");  
    $d = @mssql_select_db($myDB, $s) or die("Couldnt open database $myDB"); 
    问题:不能连接mssql
      

  2.   

    1、你原贴中是 odbc_connect 报错,给出的代码却是 mssql_connect。你不觉得有问题吗?
    2、你#2给出的代码不符合 php 语法约定(字符串应以引号括起)和屏蔽了错误信息(@),请修改并测试后再行提问
      

  3.   

    Fatal error: Call to undefined function mssql_connect() in D:\webcome\renrenup.com\newfile.php on line 12按照你的要求改后出现的以上错误; 以mssql_connect为基准
      

  4.   

    这不就是了?
    undefined function mssql_connect() 是因为你没有加载 php_mssql 扩展
      

  5.   

    以下步骤我有进行过,但还是出现了这个问题:求救!!!!!!!!1.打开php.ini,将;extension=php_mssql.dll前面的分号(;)去掉2.把 php 目录下的 ntwdblib.dll 和 php_mssql.dll 复制到 system32的系统目录中去。
      

  6.   

    http://bbs.csdn.net/topics/80187247重启服务器试试
      

  7.   

    使用 phpinfo 函数观看你的 php.ini 的位置是否正确
      

  8.   

    与php.ini里的配置路径 相同
      

  9.   

    Configuration File (php.ini) Path    
    Loaded Configuration File  
      

  10.   

    你修改的是 C:\WINDOWS\php.ini 吗?
      

  11.   

    我修改的是D:\php\php5 里面的php.ini。
      

  12.   

    但 php 使用的是 Loaded Configuration File 指向的 php.ini
      

  13.   

    2处的php.ini 都是相同的,因为我从D:\php\php5\下  复制到 C:\WINDOWS\下
      

  14.   

    <?php
    $connection_string = 'DRIVER={SQL Server};SERVER=localhost,1433;DATABASE=netsales';
    $user = 'wyz_newgou';
    $pass = 'wyz_168168';
    $connection = odbc_connect( $connection_string, $user, $pass )    OR    die("??");
    if($connection)   printf   ("Connected    successfully");   $sql="select * from W_Member";
    $result=mysql_query($sql); while ($row = mysql_fetch_assoc($result)){     
          echo "$row[M_id]";
    }
    ?>
    数据库连接成功(打印出Connected    successfully)
    但是,执行下面的语句时候出现以下错误:
    Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\webcome\renrenup.com\newfile.php on line 31Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in D:\webcome\renrenup.com\newfile.php on line 31Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\webcome\renrenup.com\newfile.php on line 33
    求解!!!!!!!!!!!!!!!!!!
      

  15.   

    你在ms sql的情况下用mysql的语句查询能得到结果?
      

  16.   

    我用php操作sql server 2005数据库。
    可以吗?
      

  17.   


    1.查询之前选择数据库: mssql_select_db('yourDB',$connection_string); 
    2.mysql_query  换成 mssql_query 试试.
    ....其他问题类似
      

  18.   

    但是,执行下面的语句时候出现以下错误:
    Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\webcome\renrenup.com\newfile.php on line 311)首先你要保证你链接sqlserver的方式正确,比如,连接地址,用户名,密码,数据库。Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in D:\webcome\renrenup.com\newfile.php on line 312)检查你的mssql的配置Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\webcome\renrenup.com\newfile.php on line 333)检查连接数据库信息
      

  19.   

    你 #18 使用 odbc 连接的数据库
    怎么又用 mssql 函数操作呢?
    ....
    $sql = "select yop 10 * from W_Member";
    $result = odbc_exec($connection, $sql);
    while ($row = odbc_fetch_array($result)){     
          print_r($row);
    }
      

  20.   

    怎么又是 odbc 和 mysql 混用?
      

  21.   

    Call to undefined function mssql_connect()我想用普通的方式连接mssql,但是老是出现这个错误,有哪些可能啊?
    odbc有点复杂  操作数据库也有点问题! 
      

  22.   


    如果你php.ini加载正确,如果你的mssql扩展已经开启并已经重启服务,还是如此,那么你可以试一试在apache配置文件末尾加入一段:
    LoadFile "xxx/xxx.dll"
    并重启服务试一试