Suljettu

Script Updated for XAMPP

I have a PHP web script that works just fine on my server here:

[url removed, login to view]

But when I try to run it on my local machine using XAMPP, I get the below error code. I need this to be able to run on my local machine - please help me figure out if I need to update my XAMPP settings or if the PHP code needs to be updated, and fix it so that it works. This script needs to be able to run very large text files - 10MB or more, without timing out.

Error code:

$v) { if($v >= $occ_num ) if( strpos($k,' ') ) { $arr_2_assoc[$k]=$v; $arr_2_occ_cnt+=$v; } } uasort($arr_2_assoc, 'cmp2'); $arr_2_assoc = array_reverse($arr_2_assoc); //////////////////////////////////////// //count occurences for 3 word phrase $arr_3_occ_cnt = 0; $temp_arr_3_assoc = $arr_3_assoc; $arr_3_assoc=array(); $arr_3_occ_cnt = 0; foreach ($temp_arr_3_assoc as $k=>$v) if($v >= $occ_num ) { $arr_3_assoc[$k]=$v; $arr_3_occ_cnt+=$v; } uasort($arr_3_assoc, 'cmp2'); $arr_3_assoc = array_reverse($arr_3_assoc); //////////////////////////////////////// unlink('[url removed, login to view]'); $excel = new ExcelWriter("key_den.xls"); $temp_exc_arr = $exc_arr; foreach ($temp_exc_arr as $r) $exc_arr[] = trim($r); if($_REQUEST['p_type'] == 1) { $ret_arr = calculate_word_popularity($theData, $occ_num, $exc_arr); $ret = array_reverse($ret_arr[0]); } $str = ''; $excel->writeLine(array('Total words count after exclusion is '.$ret_arr[2])); if( $_REQUEST['p_type'] == 1 && $ret) $excel->writeLine(array('Total words count is '.$ret_arr[3])); elseif( $_REQUEST['p_type'] == 2 && $arr_2_assoc ) $excel->writeLine(array('2 word phrases count is '.$arr_2_occ_cnt)); elseif( $_REQUEST['p_type'] == 3 && $arr_3_assoc ) $excel->writeLine(array('3 word phrases count is '.$arr_3_occ_cnt)); $excel->writeLine(array(($_REQUEST['p_type']==1?'Word' : 'Phrase'), 'Count', 'Occurence Percenatge')); //1 word if( $_REQUEST['p_type'] == 1 && $ret) { foreach ($ret as $r) { $r['percent'] = number_format((($r['count'] * 100) / $ret_arr[3]), 2)."%"; $excel->writeLine($r); } } elseif( $_REQUEST['p_type'] == 2 && $arr_2_assoc ) { foreach ($arr_2_assoc as $k=>$v) { $percent = number_format((($v * 100) / $arr_2_occ_cnt), 2)."%"; $excel->writeLine(array($k, $v, $percent)); } } elseif( $_REQUEST['p_type'] == 3 && $arr_3_assoc ) { $excel->writeLine(array('3 word phrase count is '.$arr_3_occ_cnt)); foreach ($arr_3_assoc as $k=>$v) { $percent = number_format((($v * 100) / $arr_3_occ_cnt), 2)."%"; $excel->writeLine(array($k, $v, $percent)); } } if( $_REQUEST['p_type'] == 1 ) { $assoc_1 = $ret_arr[3]; if( $assoc_1 ) { ?> Download Excelsheet

Total words count after exclusion is

1 word count is '; $str_one_word .=''; $str_one_word .= ''; echo $str_one_word; } } else echo 'No result exists.'; ?>

Word Count Occurence Percenatge

'.$r['word'].' '.$r['count'].' '.$r['percent'].'

Download Excelsheet

Total words count after exclusion is

2 word phrase count is $v) { $percent = number_format((($v * 100) / $arr_2_occ_cnt), 2)."%"; $str_2word_phrase = ''; $str_2word_phrase .=''; $str_2word_phrase .= ''; echo $str_2word_phrase; } } else echo 'No result exists.'; ?>

Phrase Count Occurence Percenatge

'.$k.' '.$v.' '.$percent.'

Download Excelsheet

Total words count after exclusion is

3 word phrase count is $v) { $percent = number_format((($v * 100) / $arr_3_occ_cnt), 2)."%"; $str_3word_phrase = ''; $str_3word_phrase .=''; $str_3word_phrase .= ''; echo $str_3word_phrase; } } else echo 'No result exists.'; ?>

Phrase Count Occurence Percenatge

'.$k.' '.$v.' '.$percent.'

close(); function phrases_count($exclude_words, &$str, &$arr_2_assoc, &$arr_3_assoc) { $new_string = $str; foreach($exclude_words as $filter_word) { $new_string = preg_replace("/\b".strtolower($filter_word)."\b/i", "", $new_string); // strip excluded words } $str_arr = explode(' ', $new_string); $new_arr_2 = array(); $i=0; for($j=0; $j0 && isset($new_arr_2[$i-1]) ) { if(!end_by_punc($str_arr[$j-1])) { $new_arr_2[$i-1] .= ' '.$temp_word; $arr_2_assoc[$new_arr_2[$i-1]] +=1; } } if($_REQUEST['p_type'] == 3) if($i>2) { //accumlate 3 words and make sure no punctuation chars in the middle if(count(explode(' ', $new_arr_2[$i-2])) == 2 && !end_by_punc($str_arr[$j-1])) $arr_3_assoc[$new_arr_2[$i-2].' '.$temp_word]+= 1; } //new $new_arr_2[$i] = $temp_word; $i++; } } function end_by_punc($word) { global $puc_chars; $last_char = substr($word, strlen($word)-1, 1); return in_array($last_char , $puc_chars); } //////////////////////////////////////////////////////////////////////// function cmp2($a, $b) { if ($a == $b) { return 0; } return ($a < $b) ? -1 : 1; } function calculate_word_popularity($string, $min_word_char = 2, $exclude_words = array()) { $string = strip_tags($string); $string = str_replace(' \' ', '', $string); $string = str_replace('-', ' ', $string); $initial_words_array = str_word_count($string, 1); $total_words = sizeof($initial_words_array); $new_string = $string; foreach($exclude_words as $filter_word) { $new_string = preg_replace("/\b".strtolower($filter_word)."\b/i", "", $new_string); // strip excluded words } //count after exclude $total_words_after_exclude = sizeof(str_word_count($new_string, 1)); $words_array = str_word_count(strtolower($new_string), 1); $words_array = array_filter($words_array, create_function('$var', 'return (strlen($var) >= '.$min_word_char.');')); $popularity = array(); $unique_words_array = array_unique($words_array); $grand_total = 0; foreach($unique_words_array as $key => $word) { preg_match_all('/\b'.$word.'\b/i', $string, $out); $count = count($out[0]); if($count < $min_word_char) continue; $percent = number_format((($count * 100) / $total_words_after_exclude), 2); $popularity[$key]['word'] = $word; $popularity[$key]['count'] = $count; $popularity[$key]['percent'] = $percent.'%'; $grand_total += $count; } /////////////////////////////////////////////////////////////////////////// function cmp($a, $b) { return ($a['count'] > $b['count']) ? +1 : -1; } usort($popularity, "cmp"); return array($popularity, $total_words, $total_words_after_exclude, $grand_total); } /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// unlink($myFile); ?>

Taidot: PHP, Komentosarjan asennus

Näytä lisää: xampp php script time, script xlsscript custom function, xampp error code, string j, string b, paul words, works global, sizeof string, large file xampp, excel xampp, xampp browse foreigners fix, export xampp excel php, words popularity php script, php xls xampp, excelw xampp, xls php type percent, xampp excel, pmb xampp, php array occurence words, run database script xampp, script words, xampp, word script, trim, str

About the Employer:
( 74 reviews ) New York, United States

Projektin tunnus: #430846