First, you should break up that huge set of nested
if statements into a set of functions so that your code is more readable.
For example, the section that reads:
Code:
//update owners stats
$URL = DB_SCRIPT_PATH . "ownerUpdate.php?ownerId=" . $ownerId;
fwrite($fp,"\t [$fileId]URL for upading Owner Stats: ".$URL." - ".date('Y-m-d H:i:s')." \n");
$cURLHandler = curl_init ();
curl_setopt ( $cURLHandler, CURLOPT_URL, $URL );
curl_exec ( $cURLHandler );
fwrite($fp,"\t [$fileId] Result From Owner Stat Update Script : ".$result." - ".date('Y-m-d H:i:s')." \n");
$URL = DB_SCRIPT_PATH . "datafile.php?action=update&uploadStatus=0filePath=m/s/".$songId."/f/".$fileId."/".$name."&fileType=" . $_FILES ['uploadfile'] ['type'] . "&fileExtension=" . $extn."&fileId=".$fileId;
fwrite($fp,"\t [$fileId]URL for upading file Stats: ".$URL." \n");
$cURLHandler = curl_init ();
curl_setopt ( $cURLHandler, CURLOPT_URL, $URL );
curl_exec ( $cURLHandler );
fwrite($fp,"\t [$fileId]Result From File Stat Update Script : ".$result." - ".date('Y-m-d H:i:s')." \n");
Could be broken off into its own function '
update_owner_stats()'.
And the section:
Code:
//request for jox to create files
$URL =SERVER_PHP_PATH." ".MIXER_SCRIPT_PATH . "joxCommandCLI.php " . $songId . " " . $fileId . " " . $extn;
fwrite($fp,"\t [$fileId]URL for Jox Request: ".$URL." - ".date('Y-m-d H:i:s')." \n");
exec($URL);
fwrite($fp,"\t [$fileId]End Time: ".date('Y-m-d H:i:s')." \n \n \n");
Could be broken off into a function called '
jox_create_file()'.
Doing this will make your program easier for you to understand (as well as for anyone else who is reading your code), and thus will make it easier for you to debug and discover/fix the problem(s) with it.
In general, whenever you've got an big set of nested
if statements, like the one in the code you posted, you should see if you can break up your logic into seperate functions somehow. You can't always do so (sometimes you actually
need a big nested if statement, but it is very often a hint that you should break it up into smaller functions.
Once you've done this, if it is still not working (i.e. if you don't just discover the problem in the process of refactoring it), then post up the new code.
--jrtayloriv