ID: 10026
Updated by: sniper
Old-Status: Open
Status: Feedback
Bug Type: *General Issues
Assigned To: 

I asked for 'self-containing' script. ie. one that doesn't
need anything outside but works as is. This example script
you added is useless and can not be used to reproduce anything. Please create a SHORT 
(max 5 lines) script that doesn't work.


Previous Comments:

[2001-04-04 06:26:22] [EMAIL PROTECTED]
The parameter passed to the function i prev. post is the stricture returned from 

- Svein


[2001-04-04 06:24:05] [EMAIL PROTECTED]
I post the function that cause the problem.
Its the for-loop int the wery bottom of the function that cause my problem. If you can 
see any wrong logic in the code please let me know :)

I have solved this problem in another way in my current code. 
The code below have worked for a long time, but stopped working and caused described 
problem after installing - i think php4.0.4 or 4.0.4pl1

Even if i surrond the for-loop with this :

echo "<br>First : $c";
if ($c!=0) {
  echo "<br>Second : $c";
  for (..) {
    echo "<br>Inside for-loop...";

the first echo output 0 but the second echo output another value like 1 or 2.
The strange thing is that if the FIRST echo output 0 the SECOND echo doesnt execute 
**BUT** the for-loop execute!

  // Parse the parts of message and get info on each
  function parseparts($ref, $ofs='') {
    global $part_no, $msg_part, $imap, $sorted_msgs, $msg_no, $bgcolor, $background, 
    global $sort_order;
    $msg_part[$part_no] = $ref;
    $msg_part[$part_no]->index = $ofs;

    $ac = count($ref->dparameters);
    for ($i=0; $i<$ac; $i++)
                if (eregi($ref->dparameters[$i]->attribute, 'filename')) {
                        $msg_part[$part_no]->filename = $ref->dparameters[$i]->value;
    $ac = count($ref->parameters);
    for ($i=0; $i<$ac; $i++)
      if (eregi($ref->parameters[$i]->attribute, 'name')) {
          $msg_part[$part_no]->name = $ref->parameters[$i]->value;
    if (!strcmp($msg_part[$part_no]->subtype, 'HTML')) { // Get background for HTML 
      $tmp = @imap_fetchbody($imap, $sorted_msgs[$msg_no-1], 
      // Encode data
      switch($msg_part[$part_no]->encoding) {
        case ENCBASE64  : $tmp = @imap_base64($tmp); break;
        case ENCQUOTEDPRINTABLE : $tmp = @imap_qprint($tmp); break;

      // Background color
      if (preg_match('/<BODY.*?BGCOLOR=([^s]+)>/si', $tmp, $tmp2)) {
        $bgcolor = 'BGCOLOR="'.preg_replace('/"/', '', $bgcolor).'"';
      } else
      // Remove any "

      // Background image
      if (preg_match('/<BODY.*?BACKGROUND=([^s]+)>/si', $tmp, $tmp2)) 

      if (!empty($tmp)) {
        $background = 
"background="getpart.phtml?1get_type=1&part_id=".rawurlencode(ereg_replace(""", '', 
      } else $background = '';

    $c = count($ref->parts);
    for ($p=0; $p<$c; $p++) {
      if (empty($ofs)) $of = ''.($p+1); else $of = $ofs.'.'.($p+1);
      parseparts($ref->parts[$p], $of);
  // Get info on each parts



[2001-04-01 13:34:29] [EMAIL PROTECTED]
As I can not reproduce this with latest CVS please try
the latest snapshot from

And if happens with it too, create one 
short but self-containing script which can be used
to reproduce this anywhere without modifications
and add it into this bug report.



[2001-03-29 12:57:01] [EMAIL PROTECTED]
When i said ONCE - i didnt mean ONCE :)
It ALWAYS happen in the code referred...


[2001-03-29 12:55:32] [EMAIL PROTECTED]
Its not easy reproduceable - i have only seen this happens ONCE - in the specified 
function. Its NOT a simple for-loop - the for-loop executes INSIDE a recursively 
called function.

I've also tried this one :
$c = count($myarray);
if ($c>0) {
  echo "c is greater than 0<br>";
  for (...) {
then IF c is 0 the echo statement doesnt execute BUT the for loop executes...

I cant figure out why...

If some of you want it i can mail you the file so you can see the things in 

- Svein


The remainder of the comments for this report are too long.  To view the rest of the 
comments, please view the bug report online.

ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to