用PHP连接sqlserver 2000

时间:2018-06-20 13:17:57

标签: php sql-server webserver

<?php   

    $serverName = "192.168.1.2";
    $connectionOptions = array('Database'=>'PKUSKH_2016', 'UID'=>'sa', 'PWD'=>'');

    $conn = sqlsrv_connect( $serverName, $connectionOptions);
    if( $conn === false )
    {
        echo "Could not connect.\n";
        die( print_r( sqlsrv_errors(), true));
    }
    else {
        echo "koneksi berhasil..!";
        echo "Data item :";

        $tsql = "select KODEKELAS,NAMAKELAS from dbo.REF_";
        $result = sqlsrv_query($conn, $tsql);

        while($row = sqlsrv_fetch_array($result))
        {
          echo($row['KODEKELAS'] . ', '.
          $row['NAMAKELAS'].'<br>');
        }

        sqlsrv_close($conn);
    }
?>

enter image description here

0 个答案:

没有答案