Forum Moderators: coopster
from
[ca.php.net...]
Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini. If seconds is set to zero, no time limit is imposed.When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.
Warning
set_time_limit() has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the php.ini.
so, is safe_mode enabled on your site?
It also really seems strange that if you set it to 0 it would override the ini settings.
to check safe mode use
[php.net...]
then look for safe_mode
$check_id is a key in index... Am I mistaken to believe that an array values can be gotten with a variable as the key? $array[$var] or what? I'm doing that and it's working sometimes and other times it isn't...
define('ROOT', dirname(__FILE__) ."/");
$file_info = ROOT ."tmp/". $_FILES['import_data']['name'];
if(move_uploaded_file($_FILES['import_data']['tmp_name'], $file_info)){
}
Errors:
Warning: move_uploaded_file(data.txt): failed to open stream: Permission denied in script.php on line 8
[Line #8 is the if statement]
Warning: move_uploaded_file(): Unable to move '/tmp/phpyCNIoo' to '{path}/data.txt' in script.php on line 8
Any idea why this is happening? This part used to work on my other server...
Am I mistaken to believe that an array values can be gotten with a variable as the key? $array[$var] or what? I'm doing that and it's working sometimes and other times it isn't...
No, you are correct. But the key (index) is non-existent in this case so you need to check for it. Take this example:
error_reporting(E_ALL);Somewhere your index is no longer defined, if it ever was at all.
$array = array(
'index1' => 'value1',
'index2' => 'value2',
'index3' => 'value3'
);
$index = 'index2';
print $array[$index]; // prints value2
unset($array[$index]);
print $array[$index]; // throws NOTICE error
It *should* still be set because it is all set at the time. I have a (2) sub arrays and a big one of the sub's combined...
[edited by: jatar_k at 6:59 pm (utc) on July 7, 2005]
[edit reason] removed full quote of coop's post [/edit]
$main_cats = array();
$sub_cats = array();
$categories = array();
foreach($cats_array as $content){
$content = str_replace("INSERT INTO C", "", $content);
$content = explode("VALUES", $content);
$tmp_names = $content['0'];
$tmp_names = str_replace("`", "", $tmp_names);
$tmp_names = explode(",", $tmp_names);
$content = trim($content['1']);
$content = explode(",", $content);
$names = array();
foreach($tmp_names as $key => $value){
$value = trim($value);
$names[$value] = $content[$key];
}
$cat_id = trim($names['id']);
if($cat_id){
if(($names['parent'] === "0") ¦¦ (!$names['parent'])){
$main_cats[$cat_id] = array("id" => "{$names['id']}", "name" => "{$names['name']}", "parent" => "{$names['parent']}", "rank" => "{$names['rank']}");
}else{
$sub_cats[$cat_id] = array("id" => "{$names['id']}", "name" => "{$names['name']}", "parent" => "{$names['parent']}", "rank" => "{$names['rank']}");
}
$categories[$cat_id] = array("id" => "{$names['id']}", "name" => "{$names['name']}", "parent" => "{$names['parent']}", "rank" => "{$names['rank']}");
}
}
ksort($main_cats);
reset($main_cats);
ksort($sub_cats);
reset($sub_cats);
ksort($categories);
reset($categories);
$categories = $main_cats + $sub_cats... There doesn't seem to be an issue/error with this part and as you may or may not be able to see I'm only using stuff that is set in the arrays...
Notice: Undefined index: the line it refers to is:$array[$check_id];
and is set earlier as:
$array[$cat_id] = array();
One thing I did notice in your earlier post is that your index is defined as two different variables. You say that the index was set earlier with $cat_id when the error is referring to $check_id.
$file_contents = implode('', file($_SESSION['import_path']));
$file_contents = explode("\n", $file_contents);
$import_data = array();
for($i=0; $i <= 60; $i++){
$content = trim($file_contents[$i]);
if($content){
$import_data[] = $content;
}
unset($file_contents[$i]);
}
$line_count = count($file_contents);
$file_contents = implode("\n", $file_contents);
$file_fp = fopen($file_info, "w");
fwrite($file_fp, $file_contents);
fclose($file_fp);
$links_array = array();
$cats_array = array();
foreach($import_data as $content){
$content = trim($content);
if($content){
if(strpos($content, 'INSERT INTO C')!== false){
$content = str_replace("'", "", $content);
$cats_array[] = $content;
}elseif(strpos($content, 'INSERT INTO L')!== false){
$links_array[] = $content;
}
}
}
The script is supposed to upload a user .txt file, break it up into certain areas and proccess the data...