Local file != remote file after upload

Ok, crazy problem here ... I feel like it's a SmartFTP problem but I can't say for sure. I'm hoping maybe somebody has seen this in the past and can maybe offer assistance.

My situation is I'm a PHP developer. I develop on windows, my staging server and production servers are both remote Linux boxes.

What keeps happening to me, to the point where I'm afraid to make any production pushes because it breaks the site every time, is this. In my most recent example, I have a PHP file that ends with these lines:




	// Clean up a keyword, remove trailing 's', then trailing apostrophes... add slahes



	function Clean($w)



	{



  $w = stripslashes($w);



  $w = preg_replace("/s$/", "", $w);



  $w = preg_replace("/'$/", "", $w);



  $w = addslashes($w);



  $w = preg_replace("/[^a-zA-Z0-9]/", " ", $w);



  $w = trim($w);



  return $w;



	}



?>




I run the code locally, no problem. I upload via SmartFTP to staging server, no problem. I upload via SmartFTP to remote server... problem. When I access any page that uses this script, which is processed before any output to the user, everything from the "o" in keyword (in the comments) until the end of the file is output, winding up before the <!DOCTYPE> tag, messing up my sessions and exposing code to the end user.

If I view source on the displayed page, I get:




ord, remove trailing 's', then trailing apostrophes... add slahes



	function Clean($w)



	{



  $w = stripslashes($w);



  $w = preg_replace("/s$/", "", $w);



  $w = preg_replace("/'$/", "", $w);



  $w = addslashes($w);



  $w = preg_replace("/[^a-zA-Z0-9]/", " ", $w);



  $w = trim($w);



  return $w;



	}



?><br />



<b>Warning</b>:  session_start(): Cannot send session cache limiter - headers already sent (output started at /home/hcblcom/hcbl.com/SearchFunc.php:113) in <b>/home/hcblcom/hcbl.com/Obj/Session.php</b> on line <b>27</b><br />



<br />



<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/hcblcom/hcbl.com/SearchFunc.php</b> on line <b>26</b><br />



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">



?>




...followed by the rest of the page. I can't fathom why it's essentially behaving as if it encountered a ?> in the middle of the word "keyword" when it did not.

To make this more frustrating, this is a recurring issue. Two other times it's occured has been towards the end of the file. I was able to "work around" the problem those times by deleting the last few lines, retyping them, saving the file, and uploading.

I also had the problem another time that was actually breaking the page - the script was dying on a fatal error making the page useless. I couldn't identify where in the 652 lines of code the problem was, and I was able to remedy this, also in a strange way. Locally, I copied the file (Checkout.php) to another file (Checkout2.php). I didn't change anything in it. I uploaded Checkout2.php to production and tested it - miraculously it worked fine. Remotely, I deleted Checkout.php, renamed Checkout2.php => Checkout.php, and that did the trick.

Since you may be wondering, I use TextPad as my editor. When I first encountered this I thought perhaps TextPad somehow slipped characters into my file that were invisible to me, but causing a problem. I used TextPad's regex search to scan the file for any non-alpha numeric. I went through every character and found nothing out of the ordinary.

I'm at my wits end dealing with this problem that just makes no sense whatsoever. If anybody has any feedback that might help me here, I would greatly appreciate it. If this turns out not to be a SmartFTP problem, a distinct possibility, then I apologize in advance for wasting your time.

T

Hello again all. Just after submitting my last post I thought about the "work around" employed last time - copying, uploading the copy, deleting the original, renaming the copy to the original. I came to the conclusion that the pivotal difference might have been that I wasn't overwriting an existing file here, but manually deleting and replacing it.

I opened up SmartFTP, erased the files I was trying to overwrite now, and then uploaded their replacements (no overwriting was done). Everything works smoothly now.

Because this happens on the production server (whose FTP server does not identify itself when connecting), and not on the staging server (identified as 'ProFTPD 1.2.10 Server'), I'm wondering now if this is an FTP server problem, and not SmartFTP.

Still, if anyone's experienced this problem I hope this saves them some time. Also if anybody from SmartFTP QA wants to poke around to be sure, they're welcome to. I've been using SmartFTP 1.5.988, and I forgot to mention that all uploads I've had a problem with were ASCII uploads, not binary.

T