Forum Moderators: coopster
<?
$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.";
}
?>
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