I am using php to access a mssql server, and any query I attempt to run with a * yeilds a Unicode 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 "
I am a LAMP developer trying to inherit a large asp site with a mssql database attached on an IIS server (ugh). I'm trying to take baby steps in getting a simple sql query though but this unicode error is baffling. Also, due to the vagueness of the problem, I havent been able to find anything on google. I also do not have the required proprietary programs needed to open up the database (I'm a notepad only kind of guy). I'm trying to get a SELECT * FROM query to work so I can see all the fields it returns. I have very limited access to the server, so any help would be appreciated, keeping that in mind.
Is there some fundamentally elementary step that I'm messing up (Like that I don't completely understand what Unicode is, or why it would be used in a D? or is there some sort of compatability issue with my server? I'm starting to think that theres a field in the db, in a format that it cannot return to my php script's mssql_query(), and hence the error but mssql documentation and help forums seem to be few and far between.
I know I'm walking into a gun fight without even a knife here, but if anyone has any clues or suggestions, I'd be glad to learn.
A query that did work was "SELECT story_id,story_headline FROM stories WHERE writer = '$_GET[writer]'". The following errors out right at die("Query has a problem : $query");. The code up top is silly with $var = $var, but the connection works.
$myServer = $server;
$myUser = $username;
$myPass = $password;
$myDB = $db;
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//declare the SQL statement that will query the database
$query = "SELECT * FROM stories";
//execute the SQL query and return records
$result = mssql_query($query)
or die("Query has a problem : $query");
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " stories" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
//display the results
while($row = mssql_fetch_array($result))
echo '<li><a href="/story.asp?story_id=' .$row['story_id']. '">' .$row["story_headline"]. "</a></li>";
//close the connection