Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6130609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:52:41+00:00 2026-05-23T16:52:41+00:00

I am getting this error Warning: fopen() expects at least 2 parameters, 1 given

  • 0

I am getting this error
Warning: fopen() expects at least 2 parameters, 1 given in C:\wamp\www\fileFormProcess.php on line 19

Warning: feof(): supplied argument is not a valid stream resource in C:\wamp\www\fileFormProcess.php on line 29

Warning: fgets(): supplied argument is not a valid stream resource in C:\wamp\www\fileFormProcess.php on line 30

Warning: Wrong parameter count for explode() in C:\wamp\www\fileFormProcess.php on line 31

I been looking over the files and can not see what I am doing wrong.
here’s my code:

<?php

if($_POST['firstName']==""|| $_POST['lastName']==""|| $_POST['address']==""||      $_POST['city']==""|| $_POST['state']==""|| $_POST['zip']==""){
header("Location:fileInsert.php?status=2");
 }
else{
$newRecord="\n";
$newRecord.=$_POST['lastName']."|".$_POST['firstName']."|".$_POST['address']."|".$_POST['city']."|".$_POST['state']."|".$_POST['zip'];

$myFile="records.txt";
$fp = fopen($myFile, "a");

//Write the data to the file
fwrite($fp, $newRecord);

//Close the file
fclose($fp);
if (file_exists($myFile)) {
$file = fopen($myFile.'r');
$rowcount=0;
echo "<html>\n";
echo " <head>\n";
echo " <title>Sucess!</title>\n";
echo " <link href=\"contact1.css\" type=\"text/css\" rel=\'stlesheet\">";
echo " </head>\n";
echo " <body>";
echo " <table width=\"75%\" cellpadding=\"2\" cellspacing=\"2\" border=\"1\">\n";
echo " <tr>\n";
while (!feof($file)) {
$line = fgets($file);
$aryData=explode("|",$line);
$firstname=$aryData[1];
$lastname=$aryData[0];
$address=$aryData[2];
$city=$aryData[3];
$state=$aryData[4];
$zip=$aryData[5];
echo "<td align=\"center\">";
echo $firstname."".lastname;
echo "<br>".$address;
echo "<br>".$city.".".$state."".$zip;
echo "</td>\n";
$rowcount++;
if ($rowcount!=0 && $rowcount%3==0){
  echo " </tr>\n";
  echo " <tr>\n";
    }

}
while($rowcount%3!=0){
 echo "<td>&nbsp;</td>\n";
 $rowcount++;
 }
 echo "</table>\n";
 }
}
echo "</body>\n";
echo " </html>\n";

and

<?php
if ($_GET['status']==2){
    $strMessage="<strong>All fields are required!</strong>";
 }
 elseif($_GET['status']==1){
     $strMessage="<strong>Your information has been added.</strong>";
}
else{
$strMessage="";
}
 ?>
 <html>
 <head>
 <link href="contact1.css" type="text/css" rel="stylesheet">
 <title>Write to a file</title>
 <style type="text/css">
fieldset{
width:50%;

 }
</style>

</head>
<body>
<?php echo $strMessage; ?>
<p>
<form name='myForm' method='post' action="fileFormProcess.php">
  <fildset><legand><i>All Fields are Required</i></legand>

  <table id='form'  border='0' cellpadding='6'>
  <tr>
<td>First Name:</td>
<td><input type='text' name='firstName'></td>
  </tr>
  <tr>
<td>Last Name:</td>
<td>
<input type='text' name='lastName'></td>
  </tr>
   <tr>
<td>Street Address:</td>
<td><input type='text' name='address'></td>
   </tr>
   <tr>
<td>City:</td>
<td><input type='text' name='city'></td>
  </tr>
  <tr>
<td>State:</td>
<td><input type='text' name='state'></td>
  </tr>
  <tr>
<td>Zip:</td>
<td><input type='text' name='zip'></td>
   </tr>
   <tr>
<td><input type='reset' value='Reset Form' name='reset'></td>
<td><input type='submit' value='Submit Form' name='submit'></td>
</tr>
  </table>
  </fieldset>
  </form>
  </p>
  </body>
  </html>

and this is the record.txt file that it is suppose to pull from

  Scott|Michael|23 Guist Rd|Scranton|PA|12345
  Beesly|Pam|4359 Justin Ave|Pittsburg|PA|44709
  Halpert|Jim|450 Sawdust Lane|Chicago|IL|55830
  Braff|Zach|33082 Buckthorn Rd|Dalton|OH|40988
  Keenan|Maynard|89 Treeview Blvd|Page Springs|AZ|85377
  Hedburg|Mitch|9000 Beerbohm Dr|Cadiz|OH|43990
  Cook|Dane|23 River Rd|Krabill|OR|66264
  Griffin|Lois|123 Our Street|Quahog|RI|48756

Now i did save the record.txt under my www wamp file i just don’t know what I did wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:52:42+00:00Added an answer on May 23, 2026 at 4:52 pm

    This $file = fopen($myFile.'r'); should be $file = fopen($myFile,'r');.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure why I am getting this error. **Warning: require_once(\C\wamp\www\PHP with
I'm getting this error: Warning: Invalid argument supplied for foreach() in [page].php on line
I'm getting an error Warning: implode() [function.implode]: Invalid arguments passed in /home/social/public_html/form_test.php on line
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
I'm getting this PHP warning in my error_log and want to get it fixed.
I'm getting this odd error in the preg_match() function: Warning: preg_match(): Compilation failed: range
I'm getting this error: Warning: mysql_connect() [function.mysql-connect]: Too many connections in /home1/host/public_html/employee/message/config.php on line
How do I fix this so my script will work. Getting this error: Warning:
What's wrong with my code? I keep getting this error: Warning: mysql_query(): supplied argument
I'm getting this error: transform.c:23: warning: ‘struct user_data_s’ declared inside parameter list transform.c:23: warning:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.