Page 1 of 2
I am getting an error in this code, simple fix i'm sure.
Posted: Tue Jun 20, 2006 11:43 pm
by akimm
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /nfs/cust/8/25/05/650528/web/add_art.php on line 40
Code: Select all
$dude = fopen($fileName, 'w') or die("can't open file");
// open the file or kill the script and show error
$numBytes = fwrite($dude, $_POST['name'] && $_POST['email'] && $_POST['article'] ");
// Write to the file with fwrite now
// FWRITE LINE BELOW IS THE LINE CAUSNG ERROR, BEFORE THAT FCLOSE WAS FOR SOME REASON.
fwrite("/article/article[$i].txt")
// Close the file handle
fclose($dude);
}
}
Re: I am getting an error in this code, simple fix i'm sure.
Posted: Tue Jun 20, 2006 11:49 pm
by tecktalkcm0391
akimm wrote:Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /nfs/cust/8/25/05/650528/web/add_art.php on line 40
Code: Select all
$dude = fopen($fileName, 'w') or die("can't open file");
// open the file or kill the script and show error
$numBytes = fwrite($dude, $_POST['name'] && $_POST['email'] && $_POST['article'] ");
// Write to the file with fwrite now
// FWRITE LINE BELOW IS THE LINE CAUSNG ERROR, BEFORE THAT FCLOSE WAS FOR SOME REASON.
fwrite("/article/article[$i].txt")
// Close the file handle
fclose($dude);
}
}
Try this:
Code: Select all
$dude = fopen($fileName, 'w') or die("can't open file");
// what to write
$write = $_POST['name'].''. $_POST['email'].''. $_POST['article'] .'';
// open the file or kill the script and show error
$numBytes = fwrite($dude, $write);
// Write to the file with fwrite now
// FWRITE LINE BELOW IS THE LINE CAUSNG ERROR, BEFORE THAT FCLOSE WAS FOR SOME REASON.
fwrite("/article/article[$i].txt")
// Close the file handle
fclose($dude);
}
}
Posted: Tue Jun 20, 2006 11:53 pm
by RobertGonzalez
Code: Select all
<?php
$dude = fopen($fileName, 'w') or die("can't open file");
// open the file or kill the script and show error
$numBytes = fwrite($dude, $_POST['name'] . ' ' . $_POST['email'] . ' ' . $_POST['article']);
/*********************************************
* The above line was causing the error with
* the phantom double quote just before the closing
* parenthesis
*********************************************/
// Write to the file with fwrite now
// FWRITE LINE BELOW IS THE LINE CAUSNG ERROR, BEFORE THAT FCLOSE WAS FOR SOME REASON.
fwrite("/article/article[$i].txt")
// Close the file handle
fclose($dude);
?>
Re: I am getting an error in this code, simple fix i'm sure.
Posted: Tue Jun 20, 2006 11:55 pm
by technofreak
akimm wrote:Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /nfs/cust/8/25/05/650528/web/add_art.php on line 40
Code: Select all
$dude = fopen($fileName, 'w') or die("can't open file");
// open the file or kill the script and show error
$numBytes = fwrite($dude, $_POST['name'] && $_POST['email'] && $_POST['article'] ");
// Write to the file with fwrite now
// FWRITE LINE BELOW IS THE LINE CAUSNG ERROR, BEFORE THAT FCLOSE WAS FOR SOME REASON.
fwrite("/article/article[$i].txt")
// Close the file handle
fclose($dude);
}
}
Think you have missed the semicolon after your --> fwrite("/article/article[$i].txt") ?! It should have been,
Code: Select all
fwrite("/article/article[$i].txt");
Was it in this post or was it in your code itself ?
Posted: Tue Jun 20, 2006 11:57 pm
by RobertGonzalez
Sweet, I am a completely blind fool.

I missed that semicolon also.
wow, thanks all for the expediant response.
Posted: Tue Jun 20, 2006 11:59 pm
by akimm
I am very greatful, as I'm blinder than all of you even everah so yea...
still an error
Posted: Wed Jun 21, 2006 12:06 am
by akimm
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /nfs/cust/8/25/05/650528/web/add_art.php on line 41
fwrite("/article/article[$i].txt")
Posted: Wed Jun 21, 2006 12:11 am
by RobertGonzalez
You got rid of the double quote at the end of the line, added the semicolon that was missing and made sure to close all brackets?
Everah
Posted: Wed Jun 21, 2006 12:15 am
by akimm
My code thus far after your improves and others imrpoves is this
Code: Select all
$dude = fopen($fileName, 'w') or die("can't open file");
// open the file or kill the script and show error
$numBytes = fwrite($dude, $_POST['name'] . $_POST['email'] . $_POST['article']);
// Write to the file with fwrite now
fwrite(article/article[$i].txt)
// Close the file handle
fclose($dude);
}
}
?>
Posted: Wed Jun 21, 2006 12:16 am
by tecktalkcm0391
Everah wrote:Sweet, I am a completely blind fool.

I missed that semicolon also.
Me too. I missed that!

Posted: Wed Jun 21, 2006 12:16 am
by tecktalkcm0391
akimm wrote:My code thus far after your improves and others imrpoves is this
Code: Select all
$dude = fopen($fileName, 'w') or die("can't open file");
// open the file or kill the script and show error
$numBytes = fwrite($dude, $_POST['name'] . $_POST['email'] . $_POST['article']);
// Write to the file with fwrite now
fwrite(article/article[$i].txt)
// Close the file handle
fclose($dude);
}
}
?>
is it working then?
Posted: Wed Jun 21, 2006 12:17 am
by RobertGonzalez
Add the semicolon...
Code: Select all
<?php
dude = fopen($fileName, 'w') or die("can't open file");
// open the file or kill the script and show error
$numBytes = fwrite($dude, $_POST['name'] . $_POST['email'] . $_POST['article']);
// Write to the file with fwrite now
fwrite(article/article[$i].txt);
// Close the file handle
fclose($dude);
?>
Posted: Wed Jun 21, 2006 12:22 am
by Robert Plank
Uhh, and quotes?
Code: Select all
fwrite("article/article[$i].txt");
A new error
Posted: Wed Jun 21, 2006 12:24 am
by akimm
it said I couldn't concoctanate .txt, I did this because I wanted to have [$i] a for loop that iterates (supposedly) each new article that is submitted, I created a variable $ext to handle the .txt file.
Parse error: parse error, unexpected T_STRING in /nfs/cust/8/25/05/650528/web/add_art.php on line 41
Code: Select all
$dude = fopen($fileName, 'w') or die("can't open file");
// open the file or kill the script and show error
$numBytes = fwrite($dude, $_POST['name'] . $_POST['email'] . $_POST['article']);
// Write to the file with fwrite now
$ext = '.txt'
fwrite(article/article . [$i] . $ext);
// Close the file handle
fclose($dude);
?>
Re: A new error
Posted: Wed Jun 21, 2006 12:37 am
by tecktalkcm0391
akimm wrote:it said I couldn't concoctanate .txt, I did this because I wanted to have [$i] a for loop that iterates (supposedly) each new article that is submitted, I created a variable $ext to handle the .txt file.
Parse error: parse error, unexpected T_STRING in /nfs/cust/8/25/05/650528/web/add_art.php on line 41
Code: Select all
$dude = fopen($fileName, 'w') or die("can't open file");
// open the file or kill the script and show error
$numBytes = fwrite($dude, $_POST['name'] . $_POST['email'] . $_POST['article']);
// Write to the file with fwrite now
$ext = '.txt'
fwrite(article/article . [$i] . $ext);
// Close the file handle
fclose($dude);
?>
Try this:
Code: Select all
$dude = fopen($fileName, 'w') or die("can't open file");
// open the file or kill the script and show error
$write = ''. $_POST['name'] . $_POST['email'] . $_POST['article'] .'';
// create what to write
// I suggest this instead of putting it directly in the fwrite();
$numBytes = fwrite($dude, $write);
// Write to the file with fwrite now
$ext = '.txt';
fwrite("article/article . [$i] . $ext");
// Close the file handle
fclose($dude);
?>