1

I have a problem, obviosly with php script. I am trying to get some data from mssql but I am getting an error:

Warning: mssql_query() [function.mssql-query]: message: 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. (severity 16) in /var/www/mssql_test_saop.php on line 63

Warning: mssql_query() [function.mssql-query]: Query failed in /var/www/mssql_test_saop.php on line 63 Rezultati za:

SELECT * FROM VseClaniceISPAPDokument

This is structure of table VseClaniceISPAPDokument

    ([NazivPU] [nvarchar](20) NULL,
    [MesObr] [nvarchar](20) NULL,
    [LetoObr] [nvarchar](20) NULL,
    [IspapXML] [xml] NULL)

This is php script:

    <!doctype html>
    <html class="no-js" lang="">
    <head>
    <meta charset="windows-1250">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title></title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type="text/css">
        table * {
            font-family: "Arial Narrow";
            font-size: 10px;
        }
     </style>
     </head>
     <body>
     <pre><?

      // Server in the this format: <computer>\<instance name> or
      // <server>,<port> when using a non default port number
      $server = '10.10.10.110:51541';

      // Connect to MSSQL
      $link = mssql_connect($server, 'tinem', '****');

      $db = "saopsf"; //skupna
      //$db = "saopopn013";

      if (!$link || !mssql_select_db($db, $link)) {
     die('Unable to connect or select database!' .                       mssql_get_last_message());
      }

     // Do a simple query, select the version of
      // MSSQL and print it.
     $version = mssql_query('SELECT @@VERSION');
     $row = mssql_fetch_array($version);

      print_r($row);

     // Clean up
     mssql_free_result($version);

     ?>
      </pre>
     <?


       function run_sql($sql) {
       $query = mssql_query($sql);

       echo "Rezultati za: <pre>$sql</pre>";

       echo mssql_num_rows($query). " vrstic<br>";

       if (mssql_num_rows($query) > 0) {
        //$data = mssql_fetch_assoc($data);
       ?>
      <table border="1" style="font-size: 10;font-family: arial;">
        <tr>
            <?
            for ($i = 0; $i < mssql_num_fields($query); ++$i) {
                $field = mssql_fetch_field($query, $i);
                echo "<th>".$field->name."</th>";
            }
            ?>
        </tr>
        <?
            while ($row = mssql_fetch_assoc($query)) {
                echo "<tr>";
                foreach($row as $field) {
                    echo "<td>" . $field . "</td>";
                }
                echo "</tr>";
            }
        ?>
    </table>
      <?
     }

    mssql_free_result($query);
     }




       run_sql("SELECT * FROM VseClaniceISPAPDokument");

        ?>

Any help? Thanks in advance

3
  • May be some help here - link Commented Nov 10, 2015 at 11:11
  • thanks danjam, tds version and client charset solved that! Commented Nov 10, 2015 at 13:01
  • Nale: What version? What client charset? Commented Dec 28, 2016 at 13:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.