ID: 31702
Updated by: [EMAIL PROTECTED]
Reported By: kevin dot bray at utoronto dot ca
-Status: Open
+Status: Bogus
Bug Type: PostgreSQL related
Operating System: Mac OS X 10.3.7
PHP Version: 5.0.3
New Comment:
You're not fetching array but a single value. $send['sender'] becomes
$send[0] which is the first char of the string. Just print $send.
Previous Comments:
------------------------------------------------------------------------
[2005-01-26 11:20:38] kevin dot bray at utoronto dot ca
Description:
------------
When using pg_fetch_result to obtain field values (in
this case, strings), PHP seems to print/echo only the
first character in the value,
I'm working with the following table (forgive the odd
test values):
arkhiv=# select * from docsender;
doctitle | sender
------------------------------+----------
letter about cheese | bob
letter about cheese | george
note about peas | helen
note about peas | god
note about peas | bob
Reproduce code:
---------------
// pg_connect() code omitted above
$result = pg_query("SELECT docSender.sender FROM docSender WHERE
docSender.doctitle = 'letter about cheese'");
?>
<table>
<?
$loopCount=0;
$rowCount = pg_num_rows($result);
while ($loopCount < $rowCount){
$send = pg_fetch_result($result, $loopCount, 0);
?>
<tr>
<td>
<? print 'Author: ' . $send['sender'];
?>
</td>
<td>
<? var_dump($send);
?>
</td>
</tr>
<?
$loopCount++;
} //endwhile
?>
</table>
Expected result:
----------------
I expected to see this:
--------------------------------------------
<html>
<table>
<tr>
<td>
Author: bob</td>
<td>
string(3) "bob"
</td>
</tr>
<tr>
<td>
Author: george</td>
<td>
string(6) "george"
</td>
</tr>
</table></body>
</html>
Actual result:
--------------
Only the initial characters (ie, 'b' and 'g') of 'bob'
and 'george' appeared in the first <td> fields:
---------------------------------------------
<html>
<table>
<tr>
<td>
Author: b </td>
<td>
string(3) "bob"
</td>
</tr>
<tr>
<td>
Author: g </td>
<td>
string(6) "george"
</td>
</tr>
</table></body>
</html>
---------------------------------------------
I inserted "var_dump();" to check if
postgres was returning the entire value of the field.
Apparently it is, so the shortened string must result
from a later (ie PHP) problem.
Thank you for your attention.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=31702&edit=1