3 Replies - 1217 Views - Last Post: 03 December 2009 - 12:17 PM Rate Topic: -----

#1 fundog1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 11-September 09

NOT SURE AS TO HOW TO FIX THIS

Posted 03 December 2009 - 11:55 AM

I keep on getting an error and cannot figure out how to fix it. here is the error below.

Parse error: parse error, unexpected $end in edit.php on line 212

Any help would be appreciated.

<?php
// Character creation page

// Address error handling.
ini_set ('display_errors',1);
error_reporting (E_ALL & ~E_NOTICE);

// Define a page title and include the header.
define ('TITLE', 'The Demonik Kronicles - Character Creation');
require ('templates/header.html');

// Define character creation arrays
$type = array (1 => 'Hustling', 'Slaying', 'Hunter', 'Dragon Knight', 'Spirit', 'Demon', 'Animal', 'Warrior', 'Archer', 'Vampire', 'Werewolf');

$country = array (1 => 'Afghanistan', 'Albania', 'Algeria', 'Andorra', 'Angola', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas', 'Bahrain', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana', 'Brazil', 'Brunei', 'Bulgaria', 'Burkina Faso', 'Burundi', 'Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Central African Republic', 'Chad', 'Chile', 'China', 'Colombi', 'Comoros', 'Congo (Brazzaville)', 'Congo', 'Costa Rica', 'Cote d Ivoire', 'Croatia', 'Cuba', 'Cyprus', 'Czech Republic', 'Denmark', 'Djibouti', 'Dominica', 'Dominican Republic', 'East Timor (Timor Timur)', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia', 'Fiji', 'Finland', 'France', 'Gabon', 'Gambia,The', 'Georgia', 'Germany', 'Ghana', 'Greece', 'Grenada', 'Guatemala', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Honduras', 'Hungary', 'Iceland', 'India', 'Indonesia', 'Iran', 'Iraq', 'Ireland', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jordan', 'Kazakhstan', 'Kenya', 'Kiribati', 'Korea,North', 'Korea,South', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Latvia', 'Lebanon', 'Lesotho', 'Liberia', 'Libya', 'Liechtenstein', 'Lithuania', 'Luxembourg', 'Macedonia', 'Madagascar', 'Malawi', 'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands', 'Mauritania', 'Mauritius', 'Mexico', 'Micronesia', 'Moldova', 'Monaco', 'Mongolia', 'Morocco', 'Mozambique', 'Myanmar', 'Namibia', 'Nauru', 'Nepa', 'Netherlands', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Panama', 'Papua New Guinea', 'Paraguay', 'Peru', 'Philippines', 'Poland', 'Portugal', 'Qatar', 'Romania', 'Russia', 'Rwanda', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Vincent', 'Samoa', 'San Marino', 'Sao Tome and Principe', 'Saudi Arabia', 'Senegal', 'Serbia and Montenegro', 'Seychelles', 'Sierra Leone', 'Singapore', 'Slovakia', 'Slovenia', 'Solomon Islands', 'Somalia', 'South Africa', 'Spain', 'Sri Lanka', 'Sudan', 'Suriname', 'Swaziland', 'Sweden', 'Switzerland', 'Syria', 'Taiwan', 'Tajikistan', 'Tanzania', 'Thailand', 'Togo', 'Tonga', 'Trinidad and Tobago', 'Tunisia', 'Turkey', 'Turkmenistan', 'Tuvalu', 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States', 'Uruguay', 'Uzbekistan', 'Vanuatu', 'Vatican City', 'Venezuela', 'Vietnam', 'Yemen', 'Zambia', 'Zimbabwe');

$items = array (1 => 'Magic Quill', 'iPod', 'Mp3', 'Health Potion', 'Flare', 'Horn of the Mark', 'The Book of Thoth', 'Gleipnir', 'The Scabbard of Arthur', 'The Bone of Ullr', 'Orichalcum', 'Valaroma,Horn of Orome', 'Ulumuri,Horn of Ulmo', 'Alhalvuri,Horn of Tulkas');

$weapons = array (1 => 'Andúril,Flame of the West', 'Durins Axe', 'Invisible Sabre', 'Glamdring,Foe-hammer', 'Sting', 'Herugrim,Fierce Sword', 'Gúthwinë,Battle Friend', 'Ellesar', 'Aeglos,Snow Point', 'Cronus sickle', 'Deaths Scythe', 'Grids Rod', 'Mjolnir,the magic hammer of Thor', 'The Thunderbolts of Zeus', 'Ogmas Whip ', 'The Golden Bow,Ilmarinen', 'Vajra,the lightning bolts of Indra', 'Kongo', 'Zulfiqar', 'Excalibur');

$armor = array (1 => 'Universal Shield', 'Helm of Hador', 'Ulumuri,Horn of Ulmo', 'The Armor of Achilles ', 'The Armor of Thor', 'The Armor of Beowulf', 'The Shield of Galahad', 'The Helmet of Rostam', 'The Helmet of Hades', 'The Tarnhelm', 'The Shield of Lancelot', 'The Aegis,Zeus shield', 'Svalinn');

$gold = array (1 => '100', '200', '300');

// Defines drop-down menu functions
function drop_down_menus () {
	// Makes arrays global
	global $type;
	global $country;
	global $items;
	global $weapons;
	global $armor;
	global $gold;
	
	// Create drop-down class menu
	print 'Class: <select name="type">';
	foreach ($type as $key => $value) {
		print "<option value=\"$key\">$value</option>";
	}
	print '</select><br />';
	
	// Create drop-down country menu
	print 'Country: <select name="country">';
	foreach ($country as $key => $value) {
		print "<option value=\"$key\">$value</option>";
	}
	print '</select><br />';
	
	// Create drop-down items menu
	print 'Starting Item: <select name="item">';
	foreach ($items as $key => $value) {
		print "<option value=\"$key\">$value</option>";
	}
	print '</select><br />';
	
	// Create drop-down weapons menu
	print 'Weapons: <select name="weapons">';
	foreach ($weapons as $key => $value) {
		print "<option value=\"$key\">$value</option>";
	}
	print '</select><br />';
	
	// Create drop-down armor menu
	print 'Armor: <select name="armor">';
	foreach ($armor as $key => $value) {
		print "<option value=\"$key\">$value</option>";
	}
	print '</select><br />';
	
	// Create drop-down gold menu
	print 'Starting Gold: <select name="gold">';
	foreach ($gold as $key => $value) {
		print "<option value=\"$key\">$value</option>";
	}
	print '</select><br />';
}

// HTML Formatting
print '<td align="center"><div id="centercontent">';

// Character creation form
if (isset ($_POST['submit'])) {
		
	// Check for empty fields
	if ((empty ($_POST['char_name'])) or (empty ($_POST['email']))) {
		print 'Please enter a character name and email address.<br />';
			
	} else {
			
		// Set cookies
		setcookie ('char_name',$_POST['char_name']);
		setcookie ('char_email',$_POST['email']);
		setcookie ('type',$type[$_POST['type']]);
		setcookie ('country',$country[$_POST['country']]);
		setcookie ('item',$items[$_POST['item']]);
		setcookie ('weapons',$weapons[$_POST['weapons']]);
		setcookie ('armor',$armor[$_POST['armor']]);
		setcookie ('gold',$gold[$_POST['gold']]);
		setcookie ('character',TRUE);
			
		// Display Character
		print '<h3>Character Information</h3>';
		print 'Name: <b>' . $_POST['char_name'] . '</b><br />';
		print 'Email: <b>' . $_POST['email'] . '</b><br />';
		print 'Class: <b>' . $type[$_POST['type']] . '</b><br />';
		print 'Country: <b>' . $country[$_POST['country']] . '</b><br />';
		print 'Starting Item: <b>' . $items[$_POST['item']] . '</b><br />';
		print 'Starting Weapon: <b>' . $weapons[$_POST['weapons']] . '</b><br />';
		print 'Starting Armor: <b>' . $armor[$_POST['armor']] . '</b><br />';
		print 'Starting Gold: <b>' . $gold[$_POST['gold']] . '</b>';
			
	}
		
} else { // Display form
	
	print '<h2>Profile Editor</h2>';
	print '<p>Edit your profile on The Demonik Kronicles website!</p>';
	print '<form action="character.php" method="post">';
	print 'Character Name: <input type="text" name="char_name" size="20" value="' . $_POST['char_name'] . '"/><br />';
	print 'Email: <input type="text" name="email" size="20" value="' . $_POST['email'] . '"/><br />';
	
	// Call drop down menu function
	drop_down_menus();
}	

if (isset ($_POST['submit'])) { // Handle form

	if ( !empty ($_POST['type']) ) { // Check for the required value.
	if ( !empty ($_POST['country']) ) { // Check for the required value.
	if ( !empty ($_POST['char_name']) ) { // Check for the required value.
	if ( !empty ($_POST['char_email']) ) { // Check for the required value.
	if ( !empty ($_POST['item']) ) { // Check for the required value.
	if ( !empty ($_POST['weapons']) ) { // Check for the required value.
	if ( !empty ($_POST['armor']) ) { // Check for the required value.
	if ( !empty ($_POST['gold']) ) { // Check for the required value.
	
		if ($fp = fopen ('../member_selections/type.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/country.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/char_name.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/char_email', 'ab')) {
		if ($fp = fopen ('../member_selections/item.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/weapons.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/armor.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/gold.txt', 'ab')) {
			
			// Adjust for magic quotes
			if (ini_get ('magic_quotes_gpc')) {
				$data = stripslashes ($_POST['type']);
				$data = stripslashes ($_POST['country']);
				$data = stripslashes ($_POST['char_name']);
				$data = stripslashes ($_POST['char_email']);
				$data = stripslashes ($_POST['item']);
				$data = stripslashes ($_POST['weapons']);
				$data = stripslashes ($_POST['armor']);
				$data = stripslashes ($_POST['gold']);
			} else {
				$data = $_POST['type'];
				$data = $_POST['country'];
				$data = $_POST['char_name'];
				$data = $_POST['char_email'];
				$data = $_POST['item'];
				$data = $_POST['weapons'];
				$data = $_POST['armor'];
				$data = $_POST['gold'];
			}
		}
		}
		}
		}
		}
		}
		}
		}
			fwrite ($fp, "$data\n"); // Write the data. Use \r\n on windows
			fclose ($fp); // Close the file.
			
			// Print a message.
			print "<p>Your type has been stored.</p>";
			print "<p>Your country has been stored.</p>";
			print "<p>Your char_name has been stored.</p>";
			print "<p>Your char_email has been stored.</p>";
			print "<p>Your items have been stored.</p>";
			print "<p>Your weapons have been stored.</p>";
			print "<p>Your armor has been stored.</p>";
			print "<p>Your gold has been stored.</p>";
			
		} else { // Could not open the file.
			print "<p>Your information could not be stored due to a system error.</p>";
		}
	
		} else { // Failed to enter information.
			print "<p>Please enter your information!</p>";
		}
	
	} // End of SUBMIT IF.
			
	// Leave php and display the form.
?>

<form action="profile.php" method="post">
<p>
<input type="submit" name="submit" value="Submit!" />
</p>
</form>

<?php		
// HTML Formating
print '</div></td>';

require ('templates/footer.html'); // Need the footer.
?>

Attached image(s)

  • Attached Image
  • Attached Image
  • Attached Image
  • Attached Image

Attached File(s)


This post has been edited by fundog1: 03 December 2009 - 11:57 AM


Is This A Good Question/Topic? 0
  • +

Replies To: NOT SURE AS TO HOW TO FIX THIS

#2 RudiVisser   User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,566
  • Joined: 05-June 09

Re: NOT SURE AS TO HOW TO FIX THIS

Posted 03 December 2009 - 12:08 PM

I was going to go through your code and clean it up, but then I saw this:
if ($fp = fopen ('../member_selections/type.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/country.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/char_name.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/char_email', 'ab')) {
		if ($fp = fopen ('../member_selections/item.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/weapons.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/armor.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/gold.txt', 'ab')) {


You realise this won't actually do anything apart from open the last text file?? What are you actually trying to do??
Was This Post Helpful? 0
  • +
  • -

#3 fundog1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 11-September 09

Re: NOT SURE AS TO HOW TO FIX THIS

Posted 03 December 2009 - 12:11 PM

How do I do that?

This post has been edited by fundog1: 03 December 2009 - 12:20 PM

Was This Post Helpful? 0
  • +
  • -

#4 RudiVisser   User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,566
  • Joined: 05-June 09

Re: NOT SURE AS TO HOW TO FIX THIS

Posted 03 December 2009 - 12:17 PM

Okay, but doing this:
if ($fp = fopen ('../member_selections/type.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/country.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/char_name.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/char_email', 'ab')) {
		if ($fp = fopen ('../member_selections/item.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/weapons.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/armor.txt', 'ab')) {
		if ($fp = fopen ('../member_selections/gold.txt', 'ab')) {

is the same as doing this:
$fp = fopen ('../member_selections/type.txt', 'ab');
$fp = fopen ('../member_selections/country.txt', 'ab');
$fp = fopen ('../member_selections/char_name.txt', 'ab');
$fp = fopen ('../member_selections/char_email', 'ab');
$fp = fopen ('../member_selections/item.txt', 'ab');
$fp = fopen ('../member_selections/weapons.txt', 'ab');
$fp = fopen ('../member_selections/armor.txt', 'ab');
$fp = fopen ('../member_selections/gold.txt', 'ab');
if(!$fp) { // ....


and you know what that does, right?? You're only writing to gold.txt when you write $data.

For better readability (and flow, since you won't have so many {s to worry about. Try moving all of the isset checks into one if() statement.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1