问题
I use this code to select password field from the sql server 2012 db, and does not return any data I tried to change the field type and it did work actually I can't change the field type in the main server and I need to work with it as it is
any idea how to work around it?
<?php
$objConnect = mssql_connect("localhost:1434\MSSQLSERVER","fdi","fdifdi");
if($objConnect)
{
echo "Database Connected.<br />";
mssql_select_db('Intranett', $objConnect);
$query = mssql_query('SELECT [pass] FROM [Intranett].[dbo].[v24Brukere]');
// Check if there were any records
if (!mssql_num_rows($query)) {
echo 'No records found';
} else {
// Print a nice list of users in the format of:
// * name (username)
echo '<ul>';
while ($row = mssql_fetch_object($query)) {
echo '<li>' . $row->pass .' </li>';
}
echo '</ul>';
}
}
else
{
echo "Database Connect Failed.<br />";
echo mssql_get_last_message();
}
mssql_close($objConnect);
?>
回答1:
As far as I know, NVARCHAR
is not supported with the old and long outdated mssql-drivers. You should instead use Microsoft's SQL Server Driver for PHP.
来源:https://stackoverflow.com/questions/11095379/mssql-php-cant-select-field-type-nvarcharmax