If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > MSSQL, executing Stored Procedure not returning correct characters using JSON

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-04-10, 15:54
core000 core000 is offline
Registered User
 
Join Date: Feb 2010
Posts: 1
MSSQL, executing Stored Procedure not returning correct characters using JSON

I'm using PHP to access SQL Server Stored Procedure. However, the

characters are not returning correctly using JSON.

Database value
--------------

_ResourceGuid
'341EEB0B-9D71-4805-8380-000C53BAE950'

ResourceGuid
'341EEB0B-9D71-4805-8380-000C53BAE950'

status
'Active'


PHP Returned JSON array
-----------------------

[{"_ResourceGuid":"\u000b","Resourceguid":"\u000b", "status":"Active",".....


Code below:
-------------------

<?php

$myServer = "server";
$myUser = "user";
$myPass = "passw";
$myDB = "mydatabase";

$conn = mssql_connect($myServer, $myUser, $myPass, $myDB);



$sql ="EXEC spassetreport";

/*$result = mssql_query("SET ANSI_NULLS ON") or
die(mssql_get_last_message());*/
$result = mssql_query("SET ANSI_WARNINGS ON") or
die(mssql_get_last_message());

$data = mssql_query( $sql, $conn);


$result = array();

do {
while ($row = mssql_fetch_object($data)){
$result[] = $row;
}
}while ( mssql_next_result($data) );

echo json_encode($result);

mssql_close($conn);
?>


Thanks
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On