JPark Posted July 28, 2009 Share Posted July 28, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/167792-warning-missing-argument/ Share on other sites More sharing options...
rhodesa Posted July 28, 2009 Share Posted July 28, 2009 what is line 477 in state_entry.php? it says you aren't passing any arguments to it Quote Link to comment https://forums.phpfreaks.com/topic/167792-warning-missing-argument/#findComment-884897 Share on other sites More sharing options...
JPark Posted July 28, 2009 Author Share Posted July 28, 2009 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)? Quote Link to comment https://forums.phpfreaks.com/topic/167792-warning-missing-argument/#findComment-884922 Share on other sites More sharing options...
rhodesa Posted July 28, 2009 Share Posted July 28, 2009 no...line 477 not 777...I still don't see where write_the_results() is called...it should be on line 477 though. Is it not? Quote Link to comment https://forums.phpfreaks.com/topic/167792-warning-missing-argument/#findComment-884935 Share on other sites More sharing options...
JPark Posted July 28, 2009 Author Share Posted July 28, 2009 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) ) Quote Link to comment https://forums.phpfreaks.com/topic/167792-warning-missing-argument/#findComment-884939 Share on other sites More sharing options...
rhodesa Posted July 28, 2009 Share Posted July 28, 2009 the variables inside the function are local to that function, so you need to pass them as arguments: write_the_results($states4us, $sectors4us, $email4us); Quote Link to comment https://forums.phpfreaks.com/topic/167792-warning-missing-argument/#findComment-884946 Share on other sites More sharing options...
JPark Posted July 28, 2009 Author Share Posted July 28, 2009 I still get the errors. What I am trying to do is write the results of $states4us, $sectors4us and $email4us to a text file but only after we check to see if the posts areset, are part of an array and a CAPTCHA test has been passed. Quote Link to comment https://forums.phpfreaks.com/topic/167792-warning-missing-argument/#findComment-885033 Share on other sites More sharing options...
rhodesa Posted July 28, 2009 Share Posted July 28, 2009 if you are put the variables in as arguments when calling it, the errors WILL go away. if they are still there, you are either working with the wrong file or you use the function somewhere else and not passing the arguments Quote Link to comment https://forums.phpfreaks.com/topic/167792-warning-missing-argument/#findComment-885056 Share on other sites More sharing options...
JPark Posted July 28, 2009 Author Share Posted July 28, 2009 But why can I call the function pretty much anywhere else on the page and it works but not here? Quote Link to comment https://forums.phpfreaks.com/topic/167792-warning-missing-argument/#findComment-885173 Share on other sites More sharing options...
rhodesa Posted July 28, 2009 Share Posted July 28, 2009 can you post all the code? Quote Link to comment https://forums.phpfreaks.com/topic/167792-warning-missing-argument/#findComment-885179 Share on other sites More sharing options...
JPark Posted July 29, 2009 Author Share Posted July 29, 2009 You asked for it... <?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> Quote Link to comment https://forums.phpfreaks.com/topic/167792-warning-missing-argument/#findComment-885816 Share on other sites More sharing options...
JPark Posted July 29, 2009 Author Share Posted July 29, 2009 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/167792-warning-missing-argument/#findComment-885940 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.