peterw Posted June 17, 2010 Share Posted June 17, 2010 I have 4 functions in a functions file. functions 1 and 2 don't cause any problems functions 3 and/or 4 do but only if they are called in another file. I'm only calling function 1. Help PLEASE! Link to comment https://forums.phpfreaks.com/topic/205059-functions-file/ Share on other sites More sharing options...
Soldier Jane Posted June 17, 2010 Share Posted June 17, 2010 Code please! Could be something to do with variable scope or any other number of things. Link to comment https://forums.phpfreaks.com/topic/205059-functions-file/#findComment-1073428 Share on other sites More sharing options...
TOA Posted June 17, 2010 Share Posted June 17, 2010 functions 3 and/or 4 do but only if they are called in another file. What problems? Link to comment https://forums.phpfreaks.com/topic/205059-functions-file/#findComment-1073429 Share on other sites More sharing options...
peterw Posted June 17, 2010 Author Share Posted June 17, 2010 <?php function remove_directory($directory) { if (is_dir($directory)) { $handle = opendir($directory); while ($file = readdir($handle) ) { if ($file != "." && $file != "..") { unlink ("$directory/$file") ; } } closedir($handle); rmdir($directory); } } function read_directory($directory, $files) { $handle = opendir($directory); while ($file = readdir($handle) ) { if ($file != "." && $file != ".." && $file == $files) { return "$directory/$file"; } } closedir($handle); } function remove_files($directory) { unlink ("$directory") ; } function get_file_ext($filename) { $photo_ext = explode(".", $filename); return strtolower($photo_ext[sizeof($photo_ext) - 1]); } ?> Link to comment https://forums.phpfreaks.com/topic/205059-functions-file/#findComment-1073434 Share on other sites More sharing options...
TOA Posted June 17, 2010 Share Posted June 17, 2010 What problems? And next time use the code tags above, makes it easier for use to read it Link to comment https://forums.phpfreaks.com/topic/205059-functions-file/#findComment-1073436 Share on other sites More sharing options...
peterw Posted June 17, 2010 Author Share Posted June 17, 2010 functions 3 and/or 4 do but only if they are called in another file. What problems? It won't run the first function Link to comment https://forums.phpfreaks.com/topic/205059-functions-file/#findComment-1073437 Share on other sites More sharing options...
kenrbnsn Posted June 17, 2010 Share Posted June 17, 2010 Why do you have your own function to get the extension of a file when there is a built-in function. See pathinfo. Ken Link to comment https://forums.phpfreaks.com/topic/205059-functions-file/#findComment-1073438 Share on other sites More sharing options...
TOA Posted June 17, 2010 Share Posted June 17, 2010 It won't run the first function Just the first one? Can you post whatever code your using it in (where you're calling it from)? Why do you have your own function to get the extension of a file when there is a built-in function. See pathinfo. Ken Good point Link to comment https://forums.phpfreaks.com/topic/205059-functions-file/#findComment-1073439 Share on other sites More sharing options...
peterw Posted June 17, 2010 Author Share Posted June 17, 2010 <? include("setting.php"); include("system_function_files.php"); if ($setup_demo == "N") { $db_connect = mysql_connect($db_host, $db_username, $db_password); mysql_select_db($db_name, $db_connect) || die(mysql_error()); remove_directory("$dir_files/$area"); $sql_query = "DELETE FROM area WHERE area_id = '$area'"; mysql_query($sql_query) or die(mysql_error()); $sql_query = "DELETE FROM area_file WHERE file_area = '$area'"; mysql_query($sql_query) or die(mysql_error()); mysql_close($db_connect); } else { setcookie("warning", $setup_demo_sorry);} $destination = "filecenter.php?"; header("location:$destination"); ?> Link to comment https://forums.phpfreaks.com/topic/205059-functions-file/#findComment-1073443 Share on other sites More sharing options...
peterw Posted June 17, 2010 Author Share Posted June 17, 2010 Good issue? Link to comment https://forums.phpfreaks.com/topic/205059-functions-file/#findComment-1073459 Share on other sites More sharing options...
TOA Posted June 17, 2010 Share Posted June 17, 2010 Are you getting any errors? Link to comment https://forums.phpfreaks.com/topic/205059-functions-file/#findComment-1073461 Share on other sites More sharing options...
peterw Posted June 17, 2010 Author Share Posted June 17, 2010 Are you getting any errors? No. It just doesn't redirect. It completely ignores the rest of the code after the include Link to comment https://forums.phpfreaks.com/topic/205059-functions-file/#findComment-1073463 Share on other sites More sharing options...
TOA Posted June 17, 2010 Share Posted June 17, 2010 Are you getting any errors? No. It just doesn't redirect. It completely ignores the rest of the code after the include That doesn't mean there's no errors. It's actually likely that there are, but you have them turned off. Just including a file shouldn't cause the script to breal unless the file you're including is broken (that might be where the problem is). Try to see if you can output an error Link to comment https://forums.phpfreaks.com/topic/205059-functions-file/#findComment-1073483 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.