PHP mssql选择blob字段错误?插入blob字段

时间:2014-09-22 12:42:27

标签: php sql

我有一个PHP脚本,它从ms sql数据库中选择数据。 出现以下错误。

"PHP Warning:
  mssql_query():
  Query failed in /var/www/integration/sqlview.php on line 59,
  referer: http://*****/integration/
"

经过调查我发现一个字段是一个blob字段,当我从我的php select语句中取出它时查询有效,但是当我添加它时它失败了。但是select语句没有任何问题,因为它在sql浏览器中运行100个。     

$host = '****\sagex3';
$port = '**';
$server = $host;
$database = '***';
$user = 'sa';
$password = '****';


$link = mssql_connect ($server, $user, $password);
if (!$link)
{
die('ERROR: Could not connect: ' . mssql_get_last_message());
}

mssql_select_db($database);

$query = "
SELECT 
MSGID_0,
PARENTID_0,
MSGTYPE_0,
MSGSTATUS_0,
POLLMETHOD_0,
CLIENTNAME_0,
USERID_0,
CPY_0,
FCY_0,
PARAM1_0,
PARAM3_0,
POPULATEDDAT_0,
POPULATEDTIM_0,
STARTDAT_0,
STARTTIM_0,
ENDDAT_0,
ENDTIM_0,
RETRYONERROR_0,
RETRIES_0,
POLLERID_0,
ERRORMSG_0,
ERRORDETAIL_0 ---  when i remove this field the query works. this seems to be a blob field?
FROM PILOT.Y9CONTROL
 ";
//this is line 59
$result = mssql_query($query);
if (!$result) 
{
    $message = 'ERROR: ' . mssql_get_last_message();
    return $message;
}
else
{
    $i = 0;
    echo '<html><body><table><tr>';
    while ($i < mssql_num_fields($result))
    {
        $meta = mssql_fetch_field($result, $i);
        echo '<td>' . $meta->name . '</td>';
        $i = $i + 1;
    }
    echo '</tr>';

    while ( ($row = mssql_fetch_row($result))) 
    {
        $count = count($row);
        $y = 0;
        echo '<tr>';
        while ($y < $count)
        {
            $c_row = current($row);
            echo '<td>' . $c_row . '</td>';
            next($row);
            $y = $y + 1;
        }
        echo '</tr>';
    }
    mssql_free_result($result);

    echo '</table></body></html>';
}

 echo "done";

?>

似乎ERRORDETAIL_0是一个导致问题的blob字段。我可以绕过这个

1 个答案:

答案 0 :(得分:0)

好的,我找到了答案。 php.ini上的utf8。

一旦我改变它,它100%工作。

全部谢谢