Jump to content

Recommended Posts

Can anyone tell me what's wrong with my code..I'm trying to print the words that goes into my textarea using tags to print it in different font sizes..here's my code

 

<?php 

if(isset($_POST['submitted']))
{

if(!strlen(trim($_POST['text']))) 
{
print "<span style='color:red;font-weight:bold;'>Please enter some text!!</span><p/>";
include('form.php');

}

else {

//format text

$cloud_one_text=$_POST['text'];
$cloud_one_text=strtolower(stripslashes($cloud_one_text));
$cloud_one_text=ereg_replace('[^a-zA-Z ]+', '', $cloud_one_text);

//remove stopwords

$stopwords=array("a", "about", "above", "above", "across", "after", "afterwards", "again", "against", "all", "almost", "alone", "along", "already", "also","although","always","am","among", "amongst", "amoungst", "amount", "an", "and", "another", "any","anyhow","anyone","anything","anyway", "anywhere", "are", "around", "as", "at", "back","be","became", "because","become","becomes", "becoming", "been", "before", "beforehand", "behind", "being", "below", "beside", "besides", "between", "beyond", "bill", "both", "bottom","but", "by", "call", "can", "cannot", "cant", "co", "con", "could", "couldnt", "cry", "de", "describe", "detail", "do", "done", "down", "due", "during", "each", "eg", "eight", "either", "eleven","else", "elsewhere", "empty", "enough", "etc", "even", "ever", "every", "everyone", "everything", "everywhere", "except", "few", "fifteen", "fify", "fill", "find", "fire", "first", "five", "for", "former", "formerly", "forty", "found", "four", "from", "front", "full", "further", "get", "give", "go", "had", "has", "hasnt", "have", "he", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "him", "himself", "his", "how", "however", "hundred", "ie", "if", "in", "inc", "indeed", "interest", "into", "is", "it", "its", "itself", "keep", "last", "latter", "latterly", "least", "less", "ltd", "made", "many", "may", "me", "meanwhile", "might", "mill", "mine", "more", "moreover", "most", "mostly", "move", "much", "must", "my", "myself", "name", "namely", "neither", "never", "nevertheless", "next", "nine", "no", "nobody", "none", "noone", "nor", "not", "nothing", "now", "nowhere", "of", "off", "often", "on", "once", "one", "only", "onto", "or", "other", "others", "otherwise", "our", "ours", "ourselves", "out", "over", "own","part", "per", "perhaps", "please", "put", "rather", "re", "same", "see", "seem", "seemed", "seeming", "seems", "serious", "several", "she", "should", "show", "side", "since", "sincere", "six", "sixty", "so", "some", "somehow", "someone", "something", "sometime", "sometimes", "somewhere", "still", "such", "system", "take", "ten", "than", "that", "the", "their", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "thereupon", "these", "they", "thickv", "thin", "third", "this", "those", "though", "three", "through", "throughout", "thru", "thus", "to", "together", "too", "top", "toward", "towards", "twelve", "twenty", "two", "un", "under", "until", "up", "upon", "us", "very", "via", "was", "we", "well", "were", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "who", "whoever", "whole", "whom", "whose", "why", "will", "with", "within", "without", "would", "yet", "you", "your", "yours", "yourself", "yourselves", "the"); 
$cloud_one_text=preg_replace('/\b('.implode("|",$stopwords).')\b/i', '', $cloud_one_text);

//extract words

$cloud_one_words=explode(' ',$cloud_one_text);
$cloud_one_word_count=count($cloud_one_words);

if ($cloud_one_word_count<100)
{
print"<span style='color:red;font-weight:bold;'> You must enter atleast 100 words!</span><p/>";
include('form.php');

}

else {

print"Thanks for entering the required amount of words";
$count_words = array_count_values($cloud_one_words);
}
}
function printTags ($count_words) {
        // $tags is the array
        
        arsort($count_words);
        
        $max_size = 32; // max font size in pixels
        $min_size = 12; // min font size in pixels
        
        // largest and smallest array values
        $max_qty = max(array_values($count_words));
        $min_qty = min(array_values($count_words));
        
        // find the range of values
        $spread = $max_qty - $min_qty;
        if ($spread == 0) { // we don't want to divide by zero
                $spread = 1;
        }
        
        // set the font-size increment
        $step = ($max_size - $min_size) / ($spread);
        
        // loop through the tag array
        foreach ($count_words as $key => $value) {
                // calculate font-size
                // find the $value in excess of $min_qty
                // multiply by the font-size increment ($size)
                // and add the $min_size set above
                $size = round($min_size + (($value - $min_qty) * $step));
        
                echo '<a href="#" style="font-size: ' . $size . 'px" title="' . $value . ' things tagged with ' . $key . '">' . $key . '</a> ';
        }
}

printTagCloud($count_words);
}


else
{
include('form.php');

}

?>

 

I'm getting an error message on line 96:

 

Fatal error: Call to undefined function printTagCloud() in C:\webroot\si314\14862875\projek exp\index.php on line 96

 

PLEASE HELP ???

 

 

Link to comment
https://forums.phpfreaks.com/topic/158885-tags/
Share on other sites

Warning: arsort() expects parameter 1 to be array, null given in C:\webroot\si314\14862875\projek exp\index.php on line 66

 

Warning: array_values() [function.array-values]: The argument should be an array in C:\webroot\si314\14862875\projek exp\index.php on line 72

 

Warning: Wrong parameter count for max() in C:\webroot\si314\14862875\projek exp\index.php on line 72

 

Warning: array_values() [function.array-values]: The argument should be an array in C:\webroot\si314\14862875\projek exp\index.php on line 73

 

Warning: Wrong parameter count for min() in C:\webroot\si314\14862875\projek exp\index.php on line 73

 

Warning: Invalid argument supplied for foreach() in C:\webroot\si314\14862875\projek exp\index.php on line 85

Link to comment
https://forums.phpfreaks.com/topic/158885-tags/#findComment-837986
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.