"Missing argument 1 for function" error in PHP

Posted on 2009-05-19
Last Modified: 2013-12-12
I haven't posted the whole page's code but I will if I need to. I've just included all the parts related to this function.

I'm trying to make a function (funhc) to display the contents of an array later in the page. But when I try the code, I get the following error:
Warning: Missing argument 1 for funhc(), called in test3.php on line 338 and defined in test3.php on line 308

I have 5 different functions that work similarly and I receive the error on all of them. Could anyone help me and point out where my mistake is?
<?php do { ?>



//tests to see if the last change value is empty (therefore never set)

if (isset($row_taskshc['update'])) {


$thisday = date("Y-m-d");


//sets the last change date to a variable $date

$date = $row_taskshc['update']; 

//format the date for mktime() function -- you need day, month, year

$year = substr($date, 0,4); 

$month = substr($date, 5, 2); 

$day = substr($date, 8, 2); 

//sets the frequency to a variable $freq

$freq = $row_taskshc['freq'];

//sets the variable to hold the new date. Calculates the new date by 

//evaluating the lastchange date and adding the frequency amount measured in months

$new_datecar = date("Y-m-d", mktime(0, 0, 0, $month +$freq, $day , $year)); 

date_diff("$thisday", "$new_datecar");



if ($ndays <= 15) {

$arrhc[] = array('task' => $row_taskshc['task'], 'adate' => $new_datecar); 



} while ($row_taskshc = mysql_fetch_assoc($taskshc)); 

function funhc($arrhc) {


   {     return false;   }

	foreach($arrhc as $element) 	{

	$hc_taskelm = $element["task"];

	$hc_dateelm = $element["adate"];

	echo "<b>$hc_taskelm</b> is due on <b>$hc_dateelm</b><br /><br />";





Open in new window

Question by:kentcommunications

Accepted Solution

tg_wilk earned 125 total points
Comment Utility
If you want to be able to omit some arguments, try assigning the default value. Furthermore, checking for array seems more appropriate then checking if the argument is empty.
function funhc($arrhc = NULL) {


   {     return false;   }

        foreach($arrhc as $element)     {

        $hc_taskelm = $element["task"];

        $hc_dateelm = $element["adate"];

        echo "<b>$hc_taskelm</b> is due on <b>$hc_dateelm</b><br /><br />";



Open in new window

LVL 34

Assisted Solution

by:Beverley Portlock
Beverley Portlock earned 125 total points
Comment Utility
Your mistake is that you are calling funhc like this


rather than like this

funhc( $someVariableOrOther );

Either pass a variable or alter the function definition as tg_wilk has outlined.

Author Closing Comment

Comment Utility
Works correct now. A big thanks to both of you!

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now