Erratic == behavior
Posted: Mon Nov 21, 2005 2:02 am
So guys I have this function which handles upload to different servers thru CURL and handles returned errors and transfers them to my error handling framework... the real catch being an erratic behavior... Let's see the code
for me the code should've worked fine but the real thing being the foreach loop after if($Result==0) line executes always i.e. whether $Result is 1 or 0...
Can anyone tell me why 
Code: Select all
function upload($SITE, $TempFile, $UploadPath)
{
if($_SERVER['SERVER_NAME'] == 'media01')
$URL = 'http://media01/ramarkz/'.($SITE=='moviez'?'moviez/upload/upload.php':'giftz/upload/upload.php');
else
$URL = ($SITE=='moviez'?'http://www.somesite.com/upload/upload.php':'http://www.someothersite.com/upload/upload.php');
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array("path"=>$UploadPath, "file"=>"@$TempFile"));
list($Result, $Reason) = explode("|", curl_exec($ch));
curl_close($ch);
$Reason = explode("~~~~~", $Reason); //explode any errors into array...
if($Result==0) // if there was an error...
foreach($Reason as $anErr)
catchErr($anErr);
return $Result==0?FALSE:TRUE;;
}