riceje7 Posted November 20, 2009 Share Posted November 20, 2009 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> Link to comment https://forums.phpfreaks.com/topic/182222-fatal-error-call-to-undefined-function-insertwords/ Share on other sites More sharing options...
trq Posted November 20, 2009 Share Posted November 20, 2009 You should be getting all sorts of errors about insertwords() being redeclared. Are you sure the file is being included? Use require instead to see. Link to comment https://forums.phpfreaks.com/topic/182222-fatal-error-call-to-undefined-function-insertwords/#findComment-961564 Share on other sites More sharing options...
PFMaBiSmAd Posted November 20, 2009 Share Posted November 20, 2009 Best guess is you are either using a Word Processor or a non-English keyboard to write code with and the code you are running is not exactly what you have posted. Link to comment https://forums.phpfreaks.com/topic/182222-fatal-error-call-to-undefined-function-insertwords/#findComment-961574 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.