From:             kevin dot bray at utoronto dot ca
Operating system: Mac OS X 10.3.7
PHP version:      5.0.3
PHP Bug Type:     PostgreSQL related
Bug description:  strings returned with 'pg_fetch_result' are incomplete

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 bug report at http://bugs.php.net/?id=31702&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31702&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=31702&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=31702&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31702&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31702&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31702&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31702&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31702&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31702&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31702&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=31702&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=31702&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31702&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31702&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31702&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31702&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31702&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31702&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31702&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31702&r=mysqlcfg

Reply via email to