Jump to content

Warning: Missing Argument


JPark

Recommended Posts

I have a function on lines 28 - 62:

function write_the_results($states4us, $sectors4us, $email4us) {

$today = date('m.d.Y');

$states4us = ( isset( $_POST['states'] ) && !empty( $_POST['states'] ) )
        ? $_POST['states']
        : null;
$sectors4us = ( isset( $_POST['sectors'] ) && !empty( $_POST['sectors'] ) )
        ? $_POST['sectors']
        : null;
$email4us =( isset( $_POST['email'] ) && !empty( $_POST['email'] ) )
        ? $_POST['email']
        : null;


if (!is_null($states4us) && !is_null($states4us) )
{
	echo "<b>For testing only: </b><br />";
	foreach ($states4us as $temp)
		{
		$abbreviations=explode("-",$temp);
		$line1= $today." ^ ".$_POST['email']." ^ ".$abbreviations[0]." ^ ";
			foreach ($sectors4us as $temp)
				{
					$sectorCodes=explode("-",$temp);
					$line= $line1.$sectorCodes[0];
					$file_test='/vs/www/http_db/notify/TEST'. date('Ymd') . 'bystate.txt';
					$file_handle = fopen($file_test,'a');
					$file_write = fwrite($file_handle, "\r\n$line");
					echo $line."<br>";
				}
		}
} else {
}
}

 

and when I call it on lines 473 - 478, I get errors:

Warning: Missing argument 1 for write_the_results(), called in /vs/webdev/docs/econ/notifyme/state_entry.php on line 477 and defined in /vs/webdev/docs/econ/notifyme/state_entry.php on line 28

 

Warning: Missing argument 2 for write_the_results(), called in /vs/webdev/docs/econ/notifyme/state_entry.php on line 477 and defined in /vs/webdev/docs/econ/notifyme/state_entry.php on line 28

 

Warning: Missing argument 3 for write_the_results(), called in /vs/webdev/docs/econ/notifyme/state_entry.php on line 477 and defined in /vs/webdev/docs/econ/notifyme/state_entry.php on line 28

 

What do I do?

 

Please and thank you,

 

Joe

Link to comment
https://forums.phpfreaks.com/topic/167792-warning-missing-argument/
Share on other sites

Line 777 is

	echo COMPLETE_RESPONSE_TXT;

which is DEFINEd in an include:

define('COMPLETE_RESPONSE_TXT',<<<HTML

		<span class="forthem">
		    <p> </p>
			<p>Thank you for using the NotifyMe System for XXXXXXX.</p>
			<p>You should receive a confirmation notice by e-mail within 2 business days.</p>
			<p>You may also print this page for your records by using the button below.</p>
                <form><input type="button" value=" Print this page "
                onclick="window.print();return false;" /></form>
    		</span> 

HTML
);

 

So, is the problem I don't reference $states4us, $sectors4us or $email4us any where in lines 473 - 478 (including the DEFINEd COMPLETE_RESPONSE_TXT)?

Sorry... fingers/brain malfunction.  I meant to type 477, not 777

 

Lines 471 - 480:

else
{
write_the_results();  // This doesn't seem to write the results at all?
echo "<span class='forthem'>";
//	write_for_them();
echo "<p> </p>";
echo COMPLETE_RESPONSE_TXT;
echo $states4us. " - ".$sectors4us." - ".$email4us;
echo "</span>";
} // end if(!$captcha_match || !empty($usr_errors) || !empty($sys_errors) )

You asked for it...  :shy:

 

<?php
/* Description of stateentry.php
*
*
*
*
* Last modified: 1:13 PM 4/2/2009
**/
include('includes/naics_constants.php');
include('includes/naics.php');
include('includes/cb_text_captcha.php');

$states = ( isset( $_POST['states'] ) && !empty( $_POST['states'] ) )
        ? $_POST['states']
        : null;
$sectors= ( isset( $_POST['sectors'] ) && !empty( $_POST['sectors'] ) )
        ? $_POST['sectors']
        : null;
$email=( isset( $_POST['email'] ) && !empty( $_POST['email'] ) )
        ? $_POST['email']
        : null;


$sys_errors = array(); // errors we may not want to show the user
$usr_errors = array(); // errors we should
$captcha_match = false; // did the capcha answer pass? Assume no at start

function write_the_results() {

$today = date('m.d.Y');

$states = ( isset( $_POST['states'] ) && !empty( $_POST['states'] ) )
        ? $_POST['states']
        : null;
$sectors= ( isset( $_POST['sectors'] ) && !empty( $_POST['sectors'] ) )
        ? $_POST['sectors']
        : null;
$email=( isset( $_POST['email'] ) && !empty( $_POST['email'] ) )
        ? $_POST['email']
        : null;


if (!is_null($states) && !is_null($_POST['sectors']) )
{
	echo "<b>For testing only: </b><br />";
	foreach ($_POST['states'] as $temp)
		{
		$abbreviations=explode("-",$temp);
		$line1= $today." ^ ".$_POST['email']." ^ ".$abbreviations[0]." ^ ";
			foreach ($_POST['sectors'] as $temp)
				{
					$sectorCodes=explode("-",$temp);
					$line= $line1.$sectorCodes[0];
					$file_test='/vs/www/http_db/notify/TEST'. date('Ymd') . 'bystate.txt';
					$file_handle = fopen($file_test,'a');
					$file_write = fwrite($file_handle, "\r\n$line");
					echo $line."<br>";
				}
		}
} else {
}
}	

function write_for_them() {
echo "<b>".date('l jS \of F Y, h:i:s A')."<br />";
$states = 	$_POST['states'];
$sectors = 	$_POST['sectors'];
$email =	$_POST['email'];

	foreach($_POST['states'] as $v)
		{
		$stateName=explode("-",$v);
		echo $stateName[1]."<br>";
		}
	foreach($_POST['sectors'] as $w)
		{
		$sectorName=explode("-",$w);
		echo $sectorName[1]."<br>";
		}
echo "</b>";
}

if( isset($_POST) && !empty( $_POST ) )
{
// This section pattern matches the POSTED email.
// if it complies, use $email_label to show the email address
if(!preg_match(EMAIL_REGEX, $_POST['email']))
{
	$usr_errors[] = USR_ERR_EMAIL;
	$email_label = '<label for="email" style="' . LABEL_STYLE . '">Email Address:</label> ';
	$email_input = '<input type="text" id="email" name="email" value="' . $_POST['email'] . '" />';
}
else
{
	$email_label = '<span style="' . LABEL_STYLE . '">Email Address:</span> ';
	$email_input = htmlentities( $_POST['email'] ) . '<input type="hidden" name="email" value="' . $_POST['email'] . '" />';
}


$captcha_match = ( isset($_POST['captcha']) )? php_check_captcha($_POST['captcha']) : false;

if( isset( $_SESSION[sESS_TXT_CAPTCHA_ANSWER] ) && !$captcha_match )
	$usr_errors[] = USR_ERR_CAPCHA;

if( $captcha_match && empty($usr_errors) )
{
	// In our example we're opening $filename in append mode.
	// The file pointer is at the bottom of the file hence
	// that's where $somecontent will go when we fwrite() it.
	//

	// 'a+' - Open for reading and writing; place the file pointer
	// at the end of the file. If the file does not exist, attempt
	// to create it. 
	if ( ($file_handle = @fopen(NOTIFY_ME_STORAGE_FILE, 'a+'))!==false )
	{
      //$file_locked = true;
	  //*
		// waiting until file will be locked for writing (FILE_LOCK_TIMEOUT milliseconds as timeout)
		$startTime = microtime();
		//echo "<pre>$startTime\n";
		do
		{
			$file_locked = flock($file_handle, LOCK_EX);
			// If lock not obtained sleep for 10 - 100 milliseconds, to avoid collision and CPU load
			//var_dump($file_locked);
			if(!$file_locked)
				usleep(round(rand(10, 100)*1000));
		}
		while (!$file_locked && (microtime()-$startTime) < FILE_LOCK_TIMEOUT); 
      /**/
		// Let's make sure the file exists and is writable first.
		// lets also make sure that the user information we checked
		// so far is valid.
		if( $file_locked && is_writable( NOTIFY_ME_STORAGE_FILE ) )
		{
			foreach($process_order as $key=>$section)
			{
				if( isset( $_POST["$key"] ) && !empty( $_POST["$key"] ) )
					save_posted_naicscodes($_POST["$key"], $section[0], $section[1], $_POST['email'], $file_handle);
			}

			fclose($file_handle);
		}
		else
			$usr_errors[] = 'System is busy.';
	} else
		$sys_errors[] = "The file (" . NOTIFY_ME_STORAGE_FILE . ") is not writable";

}
}
/**/

?> 
<html>
<head>
</head>
<body>

	    <h2>NotifyMe :: Confirmation</h2>
<?php
// for each $cat
if(!$captcha_match )
{
?> 
		<!-- START NOTIFYME FORM -->
		<form action="<?=$_SERVER['PHP_SELF'];?>" method="post">

<?php
// write_the_results();  This will write the results -- but before the CAPTCHA check etc.  NOT GOOD!

echo "<br>";

$states_count= count($_POST['states']);
$sectors_count= count($_POST['sectors']);
$combined_count= ($states_count + $sectors_count);

if ( ($states_count == 0) || ($sectors_count == 0) )
{
	echo "<span class='notice'>Please correct the following:";
		echo "<ul>";
			if ($states_count == 0 ) {
				echo "<li>You have not selected any states.</li>";
				}
			if ($sectors_count == 0 ) {
				echo "<li>You have not selected any sectors.</li>";
				}
		echo "</ul></span>";
}



if (is_array($states) && isset($states) )
{
	if ($states_count > 0) {
		echo "<b>You have selected the following state(s):</b><br><blockquote>";
			foreach($_POST['states'] as $v)
				{
					if ( in_array($v, $states, TRUE) )
					$stateName=explode("-",$v);
					echo $stateName[1]."<br>";
				}
		echo "</blockquote>";
	} 
		else 
			{
			}
	}

if (is_array($sectors) && isset($sectors) )
{
	if ($sectors_count > 0) {
		echo "<b>You have selected the following sector(s):</b><br><blockquote>";
			foreach($_POST['sectors'] as $w)
			{
				if( in_array($w, $sectors, TRUE) )
					{
					$sectorName=explode("-",$w);
					echo $sectorName[1]."<br>";
					}
			}
		echo "</blockquote>";
	} 
		else 
			{
			}
		}



if($combined_count)
{
	if( !isset($_SESSION['seen_captcha_message_once']) )
	{
?>
			<h3>You are almost done...</h3>

              <p>Please show us that you are a real person and not a web robot 
                by answering the following mathematical question.</p>

              <p class="note">Please note that your answer must be spelled out 
                (example, 'two' or 'Two') and not numeric (example, '2').</p>
			<p>Entering the correct answer and clicking Submit Form will complete your registration.</p>
			<p> </p>
<?php
		$_SESSION['seen_captcha_message_once'] = null; // it's existance, not it's value is being tested.
	} // end if( !isset($_SESSION['seen_captcha_message_once']) )
?>
			<table style="<?=TABLE_STYLE;?>">
				<tr>
					<td style="<?=TABLE_TDROW1_STYLE;?>"><?=$email_label;?></td>
					<td style="<?=TABLE_TDROW1_STYLE;?>"><?=$email_input;?></td>
				</tr>
				<tr>
					<td style="<?=TABLE_TDROW2_STYLE;?>"><label for="captcha" style="<?=LABEL_STYLE;?>"><?=php_generate_captcha();?></label><br/>
					<small><?=TXT_CAPTCHA_EXAMPLE;?></small></td>
					<td style="<?=TABLE_TDROW2_STYLE;?>"><input type="text" id="captcha" name="captcha" /></td>
				</tr>
				<tr>
					<td colspan="2"><input type="submit" value="<?=ENTRY_SUBMIT_TEXT;?>" /></td>
				</tr>
			</table>
		</form>
		<!-- END NOTIFYME FORM -->
<?php
} // end if($naics_code_count)
else
	echo '<input type="button" value="Go Back" onclick="history.go(-1); return true;" />';
} // else if(!$captcha_match || !empty($usr_errors) || !empty($sys_errors) )
else
{
write_the_results();  // This doesn't seem to write the results at all?
echo "<span class='forthem'>";
//	write_for_them();
echo "<p> </p>";
echo COMPLETE_RESPONSE_TXT;
echo "</span>";
} // end if(!$captcha_match || !empty($usr_errors) || !empty($sys_errors) )
?>
</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.