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! Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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]); } ?> Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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"); ?> Quote Link to comment Share on other sites More sharing options...
peterw Posted June 17, 2010 Author Share Posted June 17, 2010 Good issue? Quote Link to comment Share on other sites More sharing options...
TOA Posted June 17, 2010 Share Posted June 17, 2010 Are you getting any errors? Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.