Help with SQL

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
afkeuarchangel
Registered User
Posts: 9
Joined: Tue Nov 29, 2005 3:44 pm

Help with SQL

Post by afkeuarchangel »

Hi

I am making a page to display results of matches. See HERE

There are 2 boxs to input information... i want either box to be able to be used... then the filled in info to go into my sql database..

The first box works like a dream but the second just wont input anything to the sql database.. i have created all the tables and everything..

and this line is in includes/constants.php

Code: Select all

define('NEXTMATCH_TABLE', $table_prefix.'nextmatches');
Here is the php page..

Code: Select all

<?php

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_MATCHES);
init_userprefs($userdata);
//
// End session management
//

//if ( $userdata['user_level'] == ADMIN ) // Comment out this line and replace with one before if you would like your MODS to be able to add/edit/delete matches
if ( ($userdata['user_id'] == 2) || ( $userdata['user_id'] == 185) )
{
	$template->assign_block_vars('switch_user_match', array());
	$template->assign_block_vars('switch_next_match', array());
}

if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
{
	$mode = ( isset($HTTP_POST_VARS['mode']) ) ? htmlspecialchars($HTTP_POST_VARS['mode']) : htmlspecialchars($HTTP_GET_VARS['mode']);
}

if ( $mode == 'update' )
{
$mode = '';

	$current_time = time();
	
	if ( !empty($HTTP_POST_VARS['vs']) && !empty($HTTP_POST_VARS['vsabbr']) && !empty($HTTP_POST_VARS['vswww']) && !empty($HTTP_POST_VARS['rules']) && !empty($HTTP_POST_VARS['result']) && !empty($HTTP_POST_VARS['wardate']) && !empty($HTTP_POST_VARS['warimages1']) && !empty($HTTP_POST_VARS['warimages2']) && !empty($HTTP_POST_VARS['warimages3']) && !empty($HTTP_POST_VARS['score']) && !empty($HTTP_POST_VARS['rundown']) )
	
	{

		$sql = "INSERT INTO " . MATCH_TABLE . " (`match_id`, `match_clan`, `match_clanabbr`, `match_vs`, `match_vsabbr`, `match_vswww`, `match_images1`, `match_images2`, `match_images3`, `match_date`, `match_added`, `match_rules`, `match_result`, `match_scores`, `match_rundown`)
			VALUES (NULL, '" . $HTTP_POST_VARS['match_clan'] . "', '" . $HTTP_POST_VARS['match_clanabbr'] . "', '" . $HTTP_POST_VARS['vs'] . "', '" . $HTTP_POST_VARS['vsabbr'] . "', '" . $HTTP_POST_VARS['vswww'] . "', '" . $HTTP_POST_VARS['warimages1'] . "', '" . $HTTP_POST_VARS['warimages2'] . "', '" . $HTTP_POST_VARS['warimages3'] . "', '" . $HTTP_POST_VARS['wardate'] . "', '" . $current_time . "', '" . $HTTP_POST_VARS['rules'] . "', '" . $HTTP_POST_VARS['result'] . "', '" . $HTTP_POST_VARS['score'] . "', '" . $HTTP_POST_VARS['rundown'] . "')";
		if ( !($result = $db->sql_query($sql)) )
		{
				message_die(GENERAL_ERROR, 'Could not get shoutbox information', '', __LINE__, __FILE__, $sql);
		}

		redirect(append_sid("matches.php", true));

	} else {
	
		message_die(GENERAL_ERROR, 'All fields must be completed<br /><br /><a href="matches.php">Return to Matches</a>');

	}
}

if ( $mode == 'nextupdate' )
{
$mode = '';
	
	if ( !empty($HTTP_POST_VARS['next']) && !empty($HTTP_POST_VARS['date']) && !empty($HTTP_POST_VARS['time']) && !empty($HTTP_POST_VARS['map']) && !empty($HTTP_POST_VARS['gt']) )
	
	{

		$sql = "INSERT INTO " . NEXTMATCH_TABLE . " (`match_nextid`, `match_next`, `match_date`, `match_time`, `match_map`, `match_gt`)
			VALUES (NULL, '" . $HTTP_POST_VARS['next'] . "', '" . $HTTP_POST_VARS['date'] . "', '" . $HTTP_POST_VARS['time'] . "', '" . $HTTP_POST_VARS['map'] . "', '" . $HTTP_POST_VARS['gt'] . "')";
		if ( !($result = $db->sql_query($sql)) )
		{
				message_die(GENERAL_ERROR, 'Could not get shoutbox information', '', __LINE__, __FILE__, $sql);
		}

		redirect(append_sid("matches.php", true));

	} else {
	
		message_die(GENERAL_ERROR, 'All fields must be completed<br /><br /><a href="matches.php">Return to Matches</a>');

	}
}

define('SHOW_ONLINE', true);

$page_title = $lang['Matches'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
	
$sql = "SELECT * 
		FROM " . MATCH_TABLE . "
		ORDER BY 'match_added' DESC
		LIMIT 0, 30";
if ( !($result = $db->sql_query($sql)) )
{
		message_die(GENERAL_ERROR, 'Could not get shoutbox information', '', __LINE__, __FILE__, $sql);
}

while ($match_row = $db->sql_fetchrow($result))
{


		$match_added = create_date($board_config['default_dateformat'], $match_row['match_added'], $board_config['board_timezone']);

		$template->assign_block_vars('matchrow', array(
			'MATCH_CLAN' => $match_row['match_clan'], 			//<- Config - config_clan
			'MATCH_CLANABBR' => $match_row['match_clanabbr'], 	//<- Config - config_clanabbr
			
			'MATCH_VS' => $match_row['match_vs'],  				//<- Change input to check list, of which you can add
			'MATCH_VSABBR' => $match_row['match_vsabbr'], 		//rival clans, so no need to reinput for rematches.
			'MATCH_VSWWW' => $match_row['match_vswww'],			//
			
			'MATCH_IMAGES1' => $match_row['match_images1'],
			'MATCH_IMAGES2' => $match_row['match_images2'],
			'MATCH_IMAGES3' => $match_row['match_images3'],
			'MATCH_DATE' => $match_row['match_date'],
			'MATCH_ADDED' => $match_added,
			'MATCH_RULES' => $match_row['match_rules'],
			'MATCH_RESULT' => $match_row['match_result'],
			'MATCH_SCORES' => $match_row['match_scores'],
			'MATCH_RUNDOWN' => $match_row['match_rundown'],
			'MATCH_NEXT' => $match_row['match_next'],
			'MATCH_DATE' => $match_row['match_date'],
			'MATCH_TIME' => $match_row['match_time'],
			'MATCH_MAP' => $match_row['match_map'],
			'MATCH_GT' => $match_row['match_gt']
	));
}

	$template->assign_vars(array(
		'HOME_NAME' => $board_config['home_name'],
		'HOME_ABBR' => $board_config['home_abbr'],
		'AGAINST' => $lang['Match_against'],
		'AGAINST_ABBR' => $lang['Match_abbr'],
		'AGAINST_WWW' => $lang['Match_www'],
		'MATCH_TYPE' => $lang['Match_type'],
		'MATCH_RUN' => $lang['Match_run'],
		'WAR_IMAGES1' => $lang['War_images1'],
		'WAR_IMAGES2' => $lang['War_images2'],
		'WAR_IMAGES3' => $lang['War_images3'],
		'WAR_DATE' => $lang['War_date'],
		'FINAL_SCORE' => $lang['Match_score'],
		'RESULT' => $lang['Match_result'],
		'VERSUS' => $lang['Versus'],
		'MATCH_NEXT' => $lang['Match_next'],
		'MATCH_DATE' => $lang['Match_date'],
		'MATCH_TIME' => $lang['Match_time'],
		'MATCH_MAP' => $lang['Match_map'],
		'MATCH_GT' => $lang['Match_gt'],
		'MATCH_PLAYERS' => $lang['Match_players'])
	);


	$template->set_filenames(array(
		'body' => 'match_body.tpl')
	);
	
$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>
All help most appreciated thanx
afkeuarchangel
Registered User
Posts: 9
Joined: Tue Nov 29, 2005 3:44 pm

Re: Help with SQL

Post by afkeuarchangel »

No one can see the problem?
afkeuarchangel
Registered User
Posts: 9
Joined: Tue Nov 29, 2005 3:44 pm

Re: Help with SQL

Post by afkeuarchangel »

....
User avatar
MHobbit
Former Team Member
Posts: 4761
Joined: Thu Mar 18, 2004 5:32 pm
Location: There and Back Again

Re: Help with SQL

Post by MHobbit »

Moved to [2.0.x] MOD Writers Discussion.
Former phpBB MOD Team member
No private support is offered.
"There’s too many things to get done, and I’m running out of days..."
Post Reply

Return to “[2.0.x] MOD Writers Discussion”