php to sql

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
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

php to sql

Post by gaogier »

Hello, this is the problem, i am installing a modifcation to my forums

this is ment to be the SQL code but it looks too much like php, and i need to have the SQL code to update the database

can you get me all 4 codes i need from this?

Code: Select all

<?php





define('IN_PHPBB', true);

$phpbb_root_path = './';

include($phpbb_root_path . 'extension.inc');

include($phpbb_root_path . 'common.'.$phpEx);

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

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

//

// Start session management

//

$userdata = session_pagestart($user_ip, PAGE_INDEX);

init_userprefs($userdata);

//

// End session management

//





if( !$userdata['session_logged_in'] )

{

	$header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';

	header($header_location . append_sid("login.$phpEx?redirect=casino_install.$phpEx", true));

	exit;

}



if( $userdata['user_level'] != ADMIN )

{

	message_die(GENERAL_MESSAGE, 'You are not authorised to access this page');

}





$page_title = 'Updating the database';

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



echo '<table width="100%" cellspacing="1" cellpadding="2" border="0" class="forumline">';

echo '<tr><th>Updating the database</th></tr><tr><td><span class="genmed"><ul type="circle">';



$current_time = time();



$sql = array();

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('chance_playprice', '2')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('chance_aceofclubs', '15')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('chance_aceofdiamonds', '20')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('chance_aceofhearts', '25')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('chance_aceofspades', '30')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('chance_onoff', 'on')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('chance_minorprize', '5')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('chance_given', '0')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('chance_taken', '0')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('chance_played', '0')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('slot_playprice', '2')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('slot_apple', '15')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('slot_banana', '20')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('slot_orange', '25')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('slot_starfruit', '30')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('slot_onoff', 'on')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('slot_minorprize', '5')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('slot_given', '0')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('slot_taken', '0')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('slot_played', '0')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('luckydice_enable', '1')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('luckydice_maxbet', '')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('luckydice_windouble', '')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('luckydice_wintriple', '')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('luckydice_winperfect', '')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('luckydice_bonussmall', '')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('luckydice_bonusbig', '')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('luckydice_played', '0')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('luckydice_taken', '0')";

$sql[] = "INSERT INTO " . $table_prefix . "config (config_name, config_value) values ('luckydice_given', '0')";



$sql[] = "CREATE TABLE " . $table_prefix  . "blackjack_refresh (

  player int(10) NOT NULL default '0',

  card1 int(3) NOT NULL default '0',

  card2 text NOT NULL,

  card3 int(3) NOT NULL default '0',

  card4 text NOT NULL

) TYPE=MyISAM";



$sql[] = "CREATE TABLE " . $table_prefix  . "keno_game (

  played int(20) NOT NULL default '0',

  points_given int(20) NOT NULL default '0',

  points_taken int(20) NOT NULL default '0'

) TYPE=MyISAM";



$sql[] = "INSERT INTO " . $table_prefix . "keno_game (played, points_given, points_taken) VALUES ('0', '0', '0')";



$sql[] = "CREATE TABLE " . $table_prefix  . "blackjack_cards (

  number int(2) NOT NULL default '0',

  value text NOT NULL

) TYPE=MyISAM";



$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('1', 'Two Of Clubs')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('2', 'Three Of Clubs')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('3', 'Four Of Clubs')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('4', 'Five Of Clubs')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('5', 'Six Of Clubs')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('6', 'Seven Of Clubs')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('7', 'Eight Of Clubs')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('8', 'Nine Of Clubs')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('9', 'Ten Of Clubs')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('10', 'Jack Of Clubs')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('11', 'Queen Of Clubs')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('12', 'King Of Clubs')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('13', 'Ace Of Clubs')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('14', 'Two Of Diamonds')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('15', 'Three Of Diamonds')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('16', 'Four Of Diamonds')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('17', 'Five Of Diamonds')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('18', 'Six Of Diamonds')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('19', 'Seven Of Diamonds')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('20', 'Eight Of Diamonds')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('21', 'Nine Of Diamonds')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('22', 'Ten Of Diamonds')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('23', 'Jack Of Diamonds')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('24', 'Queen Of Diamonds')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('25', 'King Of Diamonds')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('26', 'Ace Of Diamonds')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('27', 'Two Of Hearts')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('28', 'Three Of Hearts')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('29', 'Four Of Hearts')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('30', 'Five Of Hearts')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('31', 'Six Of Hearts')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('32', 'Seven Of Hearts')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('33', 'Eight Of Hearts')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('34', 'Nine Of Hearts')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('35', 'Ten Of Hearts')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('36', 'Jack Of Hearts')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('37', 'Queen Of Hearts')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('38', 'King Of Hearts')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('39', 'Ace Of Hearts')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('40', 'Two Of Spades')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('41', 'Three Of Spades')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('42', 'Four Of Spades')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('43', 'Five Of Spades')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('44', 'Six Of Spades')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('45', 'Seven Of Spades')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('46', 'Eight Of Spades')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('47', 'Nine Of Spades')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('48', 'Ten Of Spades')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('49', 'Jack Of Spades')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('50', 'Queen Of Spades')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('51', 'King Of Spades')";

$sql[] = "INSERT INTO " . $table_prefix . "blackjack_cards (number, value) VALUES ('52', 'Ace Of Spades')";



$sql[] = "CREATE TABLE " . $table_prefix  . "blackjack_info (

  given int(20) NOT NULL default '0',

  taken int(20) NOT NULL default '0',

  wins int(20) NOT NULL default '0',

  losses int(20) NOT NULL default '0',

  ties int(20) NOT NULL default '0',

  re_dealt int(20) NOT NULL default '0'

) TYPE=MyISAM";



$sql[] = "INSERT INTO " . $table_prefix . "blackjack_info (given, taken, wins, losses, ties, re_dealt) VALUES ('0', '0', '0', '0', '0', '0')";





for( $i = 0; $i < count($sql); $i++ )

{

	if( !$result = $db->sql_query ($sql[$i]) )

	{

		$error = $db->sql_error();



		echo '<li>' . $sql[$i] . '<br /> +++ <font color="#FF0000"><b>Error:</b></font> ' . $error['message'] . '</li><br />';

	}

	else

	{

		echo '<li>' . $sql[$i] . '<br /> +++ <font color="#00AA00"><b>Successfully updated database</b></font></li><br />';

	}

}





echo '</ul></span></td></tr><tr><td class="catBottom" height="28">&nbsp;</td></tr>';



echo '<tr><th>End</th></tr><tr><td><span class="genmed">The upgrade has completed. Please be sure to delete this file.<br />If you have run into any errors, please visit the <a href="http://www.truthofwar.com/community" target="_phpbbsupport">ToW</a> and ask someone for help.</span></td></tr>';

echo '<tr><td class="catBottom" height="28" align="center"><span class="genmed"><a href="' . append_sid("index.$phpEx") . '">Enjoy!</a></span></td></table>';



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



?>
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

What are you trying to do?
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

im trying to install a mod on phpbb forums

i done all the php code adding fine, but the install code says its not right, it comes up with errors, which I, and 5 experts have said, that its due to the password in config, but if the passwords wrong, then the forums wouldnt connect to the database.

I am now trying to do this manualry
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Are you using EasyMOD?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

And what errors are being thrown?
gaogier
Forum Contributor
Posts: 391
Joined: Wed Mar 02, 2005 1:02 pm
Location: Portsmouth, UK
Contact:

Post by gaogier »

never mind, it didnt work as there was a / missing from a different unlatted file...must be linked somehow... thanks any how
Post Reply