问题描述
我有一个PHP脚本,它从ms sql数据库中选择数据。以下错误apears。
; PHP警告:
mssql_query():
/ var中的查询失败第59行/www/integration/sqlview.php,
referer:http:// ***** / integration /
经过调查,我发现一个字段是一个blob字段,当我从我的php select语句中取出它时,查询有效,但是当我添加它时它失败了。但是select语句没有任何问题,因为它在sql浏览器中100%工作。
I have a php script wich selects data from ms sql database. the following error apears.
;PHP Warning:
mssql_query():
Query failed in /var/www/integration/sqlview.php on line 59,
referer: http://*****/integration/
Upon investigating I found that the one field is a blob field, and when i take it out of my php select statement the query works, but when i add it it fails. But there is nothing wrong with the select statement as it works 100 percent in sql browser.
<?php
$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
";
//这是第59行
//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字段。我可以解决这个问题
It seems that the ERRORDETAIL_0 is a blob field causing problems. Ho do i get around this
推荐答案
这篇关于通过php mssql blob字段选择blob字段时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!