Jump to content

Fatal error: Call to undefined function insertwords()


riceje7

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>

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.