Jump to content

Fatal error: Call to undefined function insertwords()


Recommended Posts

i'm geting this error: Fatal error: Call to undefined function insertwords() in /Users/riceje7/Sites/tag_cloud_project/processdata.php on line 40. not sure why because i have insertwords.php included and hard coded into processdata.php the script that is calling it. anyone know why this might be happening?

 

<?php
include 'db_connect.php';
include 'parsetext.php';
include 'initswords.php';
include 'countwords.php';
include 'insertwords.php';

function insertwords($input){
	foreach($input as $word => $count){
		$sql = "SELECT * FROM `tags` WHERE `tagName` = $word";
		$result = mysql_query($sql);
		$num = mysql_num_rows($result);
		if(num != 0){
			$sql = "SELECT `count` FROM `tags` WHERE `tagName` = $word";
			$result = mysql_query($sql);
			echo($result);
		}
		else if(num==0){
			$sql = "INSERT INTO `ricej`.`tags` (`tagName`, `count`) VALUES ($word, $count);";
			mysql_query($sql);
		}
	}
}


if(array_key_exists('submit2', $_POST)){
	$temptext = $_POST['text'];
	$textinput = parsetext($temptext);
}




if(array_key_exists('submit', $_POST)){
	$temp = $_FILES['textfile'];
	//var_dump($temp);
	if($temp['type'] == "text/plain" || $temp['type'] == "application/rtf" || $temp['type'] == "application/pdf"){
		$tempfile = $_FILES['textfile']['name'];
		$temptype = $_FILES['textfile']['type'];
		$uploaddir = 'textfile_backups/'; 
		$uploadfile = $uploaddir . basename($_FILES['textfile']['name']); 
		if (move_uploaded_file($_FILES['textfile']['tmp_name'], $uploadfile)) { 
			//echo "Success";
		}

	}
	else{
		//echo "Failure";
	}

	$fp = fopen($uploadfile, 'r');
	$tempfile = fread($fp, filesize($uploadfile));
	fclose($fp);
	$filearray = parsetext($tempfile);
	$wordcount = array_count_values($filearray);
	foreach ($wordcount as $word => $count) {
  			echo($word . ' occurs ' . $count . ' time(s)<BR>');
	}	
	insertwords($wordcount);
}


?>

<?php  //included
$tempfilename = "stopwords.txt";
$fp = fopen($tempfilename, "r");
$tempDATA = fread($fp, filesize($tempfilename));
fclose($fp);
?>

<?php // included
function countwords($temp){
	$tempcount = array_count_values($temp);	
	return $temparray;
}
?>

<?php // inlcluded
function insertwords($input){
	foreach($input as $word => $count){
		$sql = "SELECT * FROM `tags` WHERE `tagName` = $word";
		$result = mysql_query($sql);
		$num = mysql_num_rows($result);
		if(num != 0){
			$sql = "SELECT `count` FROM `tags` WHERE `tagName` = $word";
			$result = mysql_query($sql);
			echo($result);
		}
		else if(num==0){
			$sql = "INSERT INTO `ricej`.`tags` (`tagName`, `count`) VALUES ($word, $count);";
			mysql_query($sql);
		}
	}
}
?>
<html>
<head>
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

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.