Jump to content

Functions File


peterw

Recommended Posts

<?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

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

<?


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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.