Click here to Skip to main content
15,905,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
<?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
";

//this is line 59
PHP
$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";
?>

It seems that the ERRORDETAIL_0 is a blob field causing problems. Ho do i get around this
Posted
Updated 22-Sep-14 7:21am
v2
Comments
Kornfeld Eliyahu Peter 23-Sep-14 2:37am    
What the SQL type of that field?
What size of data it holds?

1 solution

I have found a solution. thank you. Its ut8 on php.ini.

Changed it.

Working 100% now.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900