Forum Moderators: coopster

Message Too Old, No Replies

Parse error: syntax error, unexpected T STRING in /www/example.org/d/b/z/d

         

accora

6:00 pm on Jan 12, 2008 (gmt 0)



Well I keep getting this error for this line :
a name (and also a path if the file will not be in the
I'm a noobie at php coding and this is just a little line of a simple text based game that I can't figure out what I did wrong :(.

venelin13

6:51 pm on Jan 12, 2008 (gmt 0)

10+ Year Member



You should post the full error message (probably you miss the line number?) and of course part of your code, so we can review it and find the error. It seems to be a simple one.

accora

8:33 pm on Jan 12, 2008 (gmt 0)



Ok well here is the register script and it said Line 51 it didn't write it all down when I posted.

<?
$username="(erased for security)";
$password="(erased for security)";
$database="(erased for security)";

$user=$_POST['username'];
$pass=$_POST['password'];
$email=$_POST['email'];

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$sql = "SELECT *
FROM users
WHERE Username='$user'";

// Execute the query and put results in $result

$result = mysql_query($sql);

// Get number of rows in $result. 0 if invalid, 1 if valid.

$num = mysql_numrows($result);


if ($num!= 1)
{
$query = "INSERT INTO users VALUES ('','$user','$pass','$email')";
mysql_query($query);

//stats
$query = "INSERT INTO userstats VALUES ('','1','1','1','1','1000')";
mysql_query($query);

//inventory
$query = "INSERT INTO inventory VALUES ('','1','0','0','0','0','0','0','0','0','0')";
mysql_query($query);

//equipment
$query = "INSERT INTO equipment VALUES ('','1500','1750','1000','2000','0')";
mysql_query($query);

echo "<a href='login.html'>Continue</a>";
echo "<script type='text/javascript'>document.location='login.html';</script>";

$filename ='inventory/inventory_' . $user . '.txt'; // First assign
a name (also a path if the file will not be in the
// same directory) to the file that we're going to create.

$myFile= fopen($filename,'a'); // Open the file for writing

if(! $myFile){ // Make sure the file was opened successfully

print ("Registration error due to server load. Inventory could not be
initialized. Please try again later.");

exit;
}

$string = "1¦¦1¦¦1n2¦¦0¦¦0n3¦¦0¦¦0n4¦¦0¦¦0n5¦¦0¦¦0n6¦¦0¦¦0n7¦¦0¦¦0n8¦¦0¦¦0n9¦¦0¦¦0n10¦¦0¦¦0";
// Create data to be added to the text file.

fputs($myFile, $string); // Write the data ($string) to the text file

fclose($myFile); // Closing the file after writing data to it

} else {
echo "This username is already taken, try another one.";

}
?>

accora

6:45 am on Jan 13, 2008 (gmt 0)



No one can figure this out?

jatar_k

2:52 pm on Jan 13, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



since I am not totally sure which is line 51 for you

my guess is this bit

$filename ='inventory/inventory_' . $user . '.txt'; // First assign
a name (also a path if the file will not be in the
// same directory) to the file that we're going to create.

which is missing a comment or has an extra line break, try this way

$filename ='inventory/inventory_' . $user . '.txt'; // First assign
//a name (also a path if the file will not be in the
// same directory) to the file that we're going to create.

otherwise tell me which is line 51 and I'll look again

accora

3:18 pm on Jan 13, 2008 (gmt 0)



Thank you very much it works very well now :).