0

I write SQL query and execute query work but this query add in PHP code does not work.

$query=" SELECT k_name, count(*) from k_table left join (SELECT  Split.a.value('.', 'VARCHAR(100)') AS String  FROM  (SELECT [k_id],   CAST ('<M>' + REPLACE([k_id], ',', '</M><M>') + '</M>' AS XML) AS String  FROM  t_table) AS A CROSS APPLY  String.nodes ('/M') AS Split(a))n  on n.String=k_table.id group by k_name order by count(*) ";
$result = mssql_query($query);

$numresult = mssql_num_rows($result);

Give this error

Error (mssql_query): SELECT failed because the following SET options have incorrect settings: 'ANSI_NULLS, QUOTED_IDENTIFIER, CONCAT_NULL_YIELDS_NULL, ANSI_WARNINGS, ANSI_PADDING, ARITHABORT'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.

Mickaël Leger
  • 3,345
  • 1
  • 13
  • 32
sss
  • 1
  • 2
  • 4
    Please, post your PHP code. – Zhorov Jul 18 '19 at 12:44
  • Please update your post, not answer it to put PHP code. Also, having the error message would help a lot. – Soullivaneuh Jul 18 '19 at 12:48
  • @sss Thanks. Can you execute `if ($result === false) {echo "Error (mssql_query): ".mssql_get_last_message(); exit;}` after `$result = mssql_query($query);` and post the error (if there is an error of course). PHP code seems to be correct. – Zhorov Jul 18 '19 at 12:54
  • 1
    Are you using PHP 7? If so that function has been removed, per manual `This function was REMOVED in PHP 7.0.0.` https://www.php.net/manual/en/function.mssql-query.php You likely should use PDO. – user3783243 Jul 18 '19 at 12:57
  • Turn on error reporting - https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display – waterloomatt Jul 18 '19 at 12:58

0 Answers0