Jump to content

Recommended Posts

I've been trying to figure this out since last night.

 

PLEASE help me find it.

 

$la[0] contains X-Folder: but the if test seems to think that it doesn't.

THis is a code snippet from my code.


echo "Line" . $cnt++ . ":  Part 0--" . $la[0] . "--Part 1--" . $la[1] . "--<br>\n";


produces this:

Line16: Part 0--X-Folder:--Part 1--0--

 

But the following if test condition fails:


                  if ($la[0] == "X-Folder:"){
                     $folder = $la[1];
                     echo "Line:  " . $line;
                     $tst = FALSE;
                   }

Is there any code between

 

<?php
echo "Line" . $cnt++ . ":  Part 0--" . $la[0] . "--Part 1--" . $la[1] . "--<br>\n";
?>

 

and

 

<?php
if ($la[0] == "X-Folder:"){
     $folder = $la[1];
     echo "Line:  " . $line;
     $tst = FALSE;
}
?>

Is there any code between

 

<?php
echo "Line" . $cnt++ . ":  Part 0--" . $la[0] . "--Part 1--" . $la[1] . "--<br>\n";
?>

 

and

 

<?php
if ($la[0] == "X-Folder:"){
     $folder = $la[1];
     echo "Line:  " . $line;
     $tst = FALSE;
}
?>

Nope.  Just a comment.  I put the echo line in there because I wanted to confirm that the $la array had what I thought it did.

 

Here's the more of the code just copy pasted.

 

                   echo "Line" . $cnt++ . ":  Part 0--" . $la[0] . "--Part 1--" . $la[1] . "--<br>\n";
//                   echo "Line" . $cnt++ . ":  " . $line[$cnt] . "<br>\n";

                   if ($la[0] == "X-Folder:"){
                     $folder = $la[1];
                     echo "Line:  " . $line;
                     $tst = FALSE;
                   }

 

I put the dashes before and after the variable because I wanted to see if there were any extra characters in there.

 

Thanks guys!

 

display it's value just before your test:

That's what the echo line that I have is for.

 

Thanks all for the assistance--this one's been bugging me and I'm sure it's probably a simple typo somewhere.  But I've been looking at it for so long, I'm not sure I'll be able to see it myself.

I suspect that $la[0] might contain some leading or trailing blanks, or it's managed to get some non-printing control character (or MS Word garbage) in there perhaps.  Test it thoroughly by echoing the value AND the length of the string.

Thanks for the suggestion Andy.  You were right.  Now I just need to figure out WHY.  I (or actually my PHP script) wrote the text file that this is coming from.  I'm reading a text file in and trying to pull out the value that follows the colon on the following line.

X-Folder: 0

 

Here's the code that wrote this line to the file.


   $hdrs[$i-1] = "X-Folder:  " . $folder ."\n\n";
   $headers = implode("\n", $hdrs);
   $fname = time();
   $filePath = $path . $folders[$folder] . "/";
   $filenameTMP = $filePath . "tmp/" . $fname;
   if (!$handle = fopen($filenameTMP, 'w')) {
         echo "Cannot open file ($filenameTMP)";
         exit;
   }

   // Write $somecontent to our opened file.

   $content = $headers . $message;
   if (fwrite($handle, $content) === FALSE) {
       echo "Cannot write to file ($filenameTMP)";
       exit;
   }

   fclose($handle);

 

 

Interesting theory.  But:

 

1) I thought \n was seen as ONE LINE.  A new-line character.

 

2) the $la array variable was created from this code:

$la = explode(" ",$lines[$cnt]);

 

So if anything the newline would be at the end of $la.

 

I was getting ready to post that--but decided to try something first. 

$l = strlen("\n\nX-Folder:");  //  <--returns 11 instead of 9

 

and changed the if condition to this.

if ($la[0] == "\n\nX-Folder:")  //<--still doesn't run.

 

:(

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.