Warning: Missing argument

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mrvanjohnson
Forum Contributor
Posts: 137
Joined: Wed May 28, 2003 11:38 am
Location: San Diego, CA

Warning: Missing argument

Post by mrvanjohnson »

Here's the problem, I keep getting this error message on my page
Warning: Missing argument 1 for keyword() in C:\Long\MS\Path\To\File\classes\keyword.class.php on line 14
Real quick here is what I am trying to do. I'm creating a journal application that will automatically create links based on certain keywords in the entry. It pulls the entry from the database, parses it looking for keywords from an array and then does a simple string replace. Funny thing is, it works. Even though I get the error message, it still does it's job. Working exactly as I expected it to with the exception of the annoying error message at the top of the page.

OK how about some code.

First step I drop the results of a SELECT statement into a variable

Code: Select all

<?php
$text = $bbcode -> parse_bbcode($v -> sqlOut($row['journal_text']));
?>
I think you can ignore $bbcode -> parse_bbcode($v -> sqlOut , these are some functions I use to create BBCode and do some Data Scrubbing before displaying it. Unless you think it might be picking something up in these functions (or loosing something) I then take that $text variable and pass it through my keyword function like this

Code: Select all

<?php
echo $keywords -> keyword($text);
?>
And here is what the keyword function looks like

Code: Select all

<?php
function keyword($value)  //this is line 14 of the file keyword.class.php
	{
	$keyword = array(
		"Windows 2000" => "http://www.microsoft.com/windows2000/",
		"Microsoft" => "http://www.microsoft.com/"
		);	
	foreach ($keyword as $k => $v) { 
		$value = str_replace($k, "<a href="$v" target="_blank">$k</a>", $value);
		}
	return $value ;
	}
?>
Like I said, it seems to work but I need to understand what the error is referencing so I can fix it. I did Google this but everyone seems to state the obvious, which is “your not passing one of the variables”. This does not seem to be my problem, or if it is I’m not understanding what I’m not passing.

Any ideas?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you echoed out $text to see what it contains?

Mac
Post Reply