You don't say exactly which line is causing the error, but you ought to use isset
for any variables you are not sure exist. For example:
$url_items = array("foo");
if ( isset($url_items[1]) )
{
$article_id = db_escape($url_items[1]);
$article = get_article($article_id);
}
function get_article($article_id = NULL) {.....}
You'll also want to check the content of the db_escape
method, in case that is also doing something with an undefined variable.
One other way around the problem is to pass the variable to the function by reference using &
:
function get_article(&$article_id) {
if ( $article_id == null ) {
// handle null case here
}
else {
// get the article
}
}