Pagina 1 van 1

SQL

Geplaatst: 05 feb 2006, 18:20
door The Sting
Hallo All,

Wie kan die voor mij omzetten in alleen SQL, krijg op mijn thuis proef forum, de install niet opgestart.

Code: Selecteer alles

<?php
	/*******************************************
	*                StatusMail                *
	*                ----------                *
	*                                          *
	*   date       : January 2006              *
	*   (C)/author : B.Funke                   *
	*   URL        : http://forum.beehave.de   *
	*                                          *
	********************************************/

/**
 * @package SQL Parser
 * @script install/db_update.php
 * @copyright (c) 2005 phpBB Group
 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License
 *
 * - Notes:
 *   - This script can only be run by board administrators.
 *   - First, a confirmation panel will show all SQL statements.
 *   - Your database will only be updated once the confirmation panel has been confirmed.
 */

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

//
// Language entries used in this script.
//
if ($board_config['default_lang'] == "german")
{
	$lang += array(
		'Update_confirm'			=> 'Dieses Skript wird die Datenbank mit den unten aufgef&uuml;hrten SQL-Statements aktualisieren.<br /><br />Vor dem Ausf&uuml;hren sollte ein Backup der Datenbank angefertigt werden!<hr /><table><tr><td><pre>%s</pre></td></tr></table><hr />Klicke <i>Ja</i> um fortzufahren oder <i>Nein</i>, um zum Forum-Index zur&uuml;ckzukehren.',
		'Updating_database'			=> 'Aktualisiere die Datenbank',
		'Installation_complete'		=> 'Installation komplett',
		'Delete_this_file'			=> 'Bitte l&ouml;sche das install-Verzeichnis und diese Datei jetzt aus deinem Forum-Verzeichnis.',
		'Successful'				=> 'erfolgreich'
	);
}
else
{
	$lang += array(
		'Update_confirm'			=> 'This panel will update your database with the SQL statements detailed below.<br /><br />Remember to make backups of your database before proceeding!<hr /><table><tr><td><pre>%s</pre></td></tr></table><hr />Click <i>Yes</i> to proceed or <i>No</i> to return to your board index.',
		'Updating_database'			=> 'Updating the Database',
		'Installation_complete'		=> 'Installation Complete',
		'Delete_this_file'			=> 'Please, be sure to delete your install directory and this file from your phpBB installation now.',
		'Successful'				=> 'Successful'
	);
}

//
// Session Management.
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);

//
// Only administrators here, please
//
if( !$userdata['session_logged_in'] )
{
	redirect(append_sid("login.$phpEx?redirect=".basename(__FILE__), true));
}
if( $userdata['user_level'] != ADMIN )
{
	if ( @file_exists($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx) )
	{
		include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx);
	}
	else
	{
		include($phpbb_root_path . 'language/lang_english/lang_admin.' . $phpEx);
	}
	message_die(GENERAL_MESSAGE, $lang['Not_admin']);
}

//
// Build Array of SQL Statements.
//
$sql = array();
$sql[] = 'CREATE TABLE ' . $table_prefix . 'statusmail (user_id INTEGER NOT NULL, forum_id INTEGER NOT NULL)';
$sql[] = 'ALTER TABLE ' . USERS_TABLE . ' ADD statusmail_days INTEGER NOT NULL DEFAULT 7';
$sql[] = 'ALTER TABLE ' . USERS_TABLE . ' ADD statusmail_last INTEGER NOT NULL';
$sql[] = 'ALTER TABLE ' . USERS_TABLE . ' ADD statusmail_format TINYINT NOT NULL DEFAULT 1';
$sql[] = 'UPDATE ' . USERS_TABLE . ' SET statusmail_last = user_regdate';
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_days\',\'7\')';
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_active\',\'0\')';
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_report\',\'0\')';
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_emailupdate\',\'0\')';
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_exclude\',\'\')';
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_unsubscribe\',\'\')';
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_maxmail\',\'10\')';
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_sacode\',\'go\')';

$sql_count = count($sql);

//
// Output confirmation page?
//
$cancel = isset($HTTP_POST_VARS['cancel']) ? true : false;
$confirm = isset($HTTP_POST_VARS['confirm']) ? true : false;
$mode = isset($HTTP_POST_VARS['mode']) ? trim(htmlspecialchars($HTTP_POST_VARS['mode'])) : '';

if( $cancel )
{
	redirect(append_sid("index.$phpEx", true));
}

if( !$confirm || $mode != 'db_update' )
{
	include($phpbb_root_path . 'includes/page_header.'.$phpEx);

	$template->set_filenames(array(
		'confirm_body' => 'confirm_body.tpl')
	);

	$message = sprintf($lang['Update_confirm'], implode(";\n\n", $sql));

	$s_hidden_fields = '<input type="hidden" name="mode" value="db_update" />';

	$template->assign_vars(array(
		'L_INDEX'			=> '',
		'MESSAGE_TITLE'		=> $lang['Information'],
		'MESSAGE_TEXT'		=> $message,
		'L_YES'				=> $lang['Yes'],
		'L_NO'				=> $lang['No'],
		'S_CONFIRM_ACTION'	=> append_sid(basename(__FILE__)),
		'S_HIDDEN_FIELDS'	=> $s_hidden_fields)
	);

	$template->pparse('confirm_body');

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

//
// Send Page Header.
//
$page_title = $lang['Updating_database'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

//
// Execute SQL and get Results.
//
$sql_rows = '';
for( $i = 0; $i < $sql_count; $i++ )
{
	if( !($result = $db->sql_query($sql[$i])) )
	{
		$error = $db->sql_error();
		$color = '#FF0000';
		$success = $lang['Error'] . ':';
		$errmsg = ' ' . $error['message'];
	}
	else
	{
		$color = '#00AA00';
		$success = $lang['Successful'];
		$errmsg = '';
	}
	$class = ($i%2) == 0 ? 'row1' : 'row2';
	$sql_rows .= '<tr><td class="'.$class.'"><div class="genmed">' . $sql[$i] . ';<br /><br /><b style="color:' . $color . ';">' . $success . '</b>' . $errmsg . '</div></td></tr>';
}

//
// Build the Report.
//
$click_return_index = sprintf($lang['Click_return_index'], '<a class="genmed" href="' . append_sid($phpbb_root_path . "index.$phpEx") . '">', '</a>');

$html = <<<EOT
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="forumline">
	<tr>
		<th>{$page_title}</th>
	</tr>
	<tr>
		<td>
			<table cellpadding="8" cellspacing="1" border="0" align="center">
				{$sql_rows}
			</table>
		</td>
	</tr>
	<tr>
		<td class="row3"><img src="{$phpbb_root_path}images/spacer.gif" border="0" height="4" alt="" /></td>
	</tr>
	<tr>
		<th>{$lang['Installation_complete']}</th>
	</tr>
	<tr>
		<td align="center">
			<table cellpadding="8" cellspacing="0" border="0" align="center">
				<tr>
					<td>
						<b class="gen" style="color:#EE0000;">{$lang['Delete_this_file']}</b>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td class="catBottom" align="center">
			<span class="genmed">{$click_return_index}</span>
		</td>
	</tr>
</table>
EOT;
echo $html;

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

?>

Geplaatst: 05 feb 2006, 18:28
door Paul
zet tijdelijk // voor unset($passwd); in common.php dan doet ie het wel ;) vermoed ik

Geplaatst: 05 feb 2006, 18:35
door The Sting
paulus schreef:zet tijdelijk // voor unset($passwd); in common.php dan doet ie het wel ;) vermoed ik
Nope werkt niet :oops:

Op het forum krijg ik nu deze fout:

Code: Selecteer alles

57
c:\appserv\www\includes\statusmail.php
SELECT user_id, user_email, username, user_lang, user_dateformat, user_level, user_lastvisit, statusmail_days, statusmail_last, statusmail_format FROM phpbb_users WHERE (statusmail_last+(statusmail_days*86400)) < 1139176764 AND statusmail_days > 0 AND user_active = 1 AND user_id NOT IN (-1) ORDER BY user_lang, username

DEBUG MODE

SQL Error : 1054 Unknown column 'statusmail_days' in 'field list'

Geplaatst: 05 feb 2006, 23:22
door supperbas

Geplaatst: 05 feb 2006, 23:30
door The Sting
Krijg nu deze in mijn phpadmin

Code: Selecteer alles

MySQL retourneerde:  

#1064 - You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'C' at line 1 
 

Geplaatst: 07 feb 2006, 02:02
door The Sting
bump

Geplaatst: 07 feb 2006, 10:12
door Ramon Fincken
kun je niet iedere sql regel even echo -en en dan:

SQL:
If you have phpmyadmin access to your database then go to your database and click the SQL link at the top.
Copy and paste the sql from the mod install file into the small window and click GO

If you do not have phpmyadmin access then copy and paste the sql into this http://www.phpbbstyles.com/sql.php and it will generate a PHP file that you can place in the root of phpBB2 and run with your browser.

Geplaatst: 07 feb 2006, 10:40
door The Sting
Ramon Fincken schreef:kun je niet iedere sql regel even echo -en en dan:
Nee zit zelfs op thuis server, maar om de een of andere reden wil de php niet opstarten. Daarom mijn vraag om uit mijn eerste berichtje, de sql commando's te halen, zodat ik ze via de admin kan doen. Mijn kennis over sql is nihil namelijk.

:thumb:

Geplaatst: 07 feb 2006, 15:23
door Ramon Fincken
The Sting schreef:
Ramon Fincken schreef:kun je niet iedere sql regel even echo -en en dan:
Nee zit zelfs op thuis server, maar om de een of andere reden wil de php niet opstarten. Daarom mijn vraag om uit mijn eerste berichtje, de sql commando's te halen, zodat ik ze via de admin kan doen. Mijn kennis over sql is nihil namelijk.

:thumb:

als ik je voorzie van een php installatie bestand waarmee je de sql kan runnen werkt dat dan?

Ik zag niet zo snel wat je php probleem nu precies is?

Rfn

Geplaatst: 07 feb 2006, 15:46
door supperbas
w8 ff nu raak ik ook de draad kwijt

Je hebt een forum phpbb (Is dus *.php)
En je wilt geen *.php gebruiken
:shock:

Geplaatst: 07 feb 2006, 18:35
door The Sting
supperbas schreef:w8 ff nu raak ik ook de draad kwijt

Je hebt een forum phpbb (Is dus *.php)
En je wilt geen *.php gebruiken
:shock:
Wil het wel gebruiken, maar hij doet niets, zie http://www.phpbb.nl/viewtopic.php?p=220110#220110 vandaar mijn vraag wat is nu precies de sql in die file. Want dan kan ik het via phpadmin proberen.

Sorry als ik onduidelijk was of ben :thumb:

Geplaatst: 07 feb 2006, 19:42
door supperbas
hier na komt de sql

Code: Selecteer alles

$sql[] = 

Geplaatst: 08 feb 2006, 23:35
door The Sting
supperbas schreef:hier na komt de sql

Code: Selecteer alles

$sql[] = 
Heb nu dit stuk geknipt en geplakt in sql en krijg dan onderstaande foutmelding.

Code: Selecteer alles

$sql = array(); 
$sql[] = 'CREATE TABLE ' . $table_prefix . 'statusmail (user_id INTEGER NOT NULL, forum_id INTEGER NOT NULL)'; 
$sql[] = 'ALTER TABLE ' . USERS_TABLE . ' ADD statusmail_days INTEGER NOT NULL DEFAULT 7'; 
$sql[] = 'ALTER TABLE ' . USERS_TABLE . ' ADD statusmail_last INTEGER NOT NULL'; 
$sql[] = 'ALTER TABLE ' . USERS_TABLE . ' ADD statusmail_format TINYINT NOT NULL DEFAULT 1'; 
$sql[] = 'UPDATE ' . USERS_TABLE . ' SET statusmail_last = user_regdate'; 
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_days\',\'7\')'; 
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_active\',\'0\')'; 
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_report\',\'0\')'; 
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_emailupdate\',\'0\')'; 
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_exclude\',\'\')'; 
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_unsubscribe\',\'\')'; 
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_maxmail\',\'10\')'; 
$sql[] = 'INSERT INTO ' . CONFIG_TABLE . '(config_name,config_value) VALUES(\'statusmail_sacode\',\'go\')'; 

$sql_count = count($sql); 

MySQL retourneerde:

#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '$sql = array()' at line 1

Laat ik dit

Code: Selecteer alles

$sql = array();
eruit dan krijg ik de volgende fout melding

SQL-query:

$sql[] = 'CREATE TABLE '.$table_prefix. 'statusmail (user_id INTEGER NOT NULL, forum_id INTEGER NOT NULL)'
MySQL retourneerde:

#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '$sql[] = 'CREATE TABLE ' . $table_prefix . 'statusmail (user_id

Geplaatst: 08 feb 2006, 23:38
door -=|Rik|=-
Natuurlijk krijg je foutmeldingen. Dat is namelijk nog geen volledige sql.

Ten eerste $sql[] = " hoort er niet bij.

$prefix herkent die uberhaupt niet, USER_TABLE is hem ook vreemd. Je moet even die dingen vervangen door hun juiste waarde.

Geplaatst: 08 feb 2006, 23:42
door The Sting
-=|Rik|=- schreef:Natuurlijk krijg je foutmeldingen. Dat is namelijk nog geen volledige sql.

Ten eerste $sql[] = " hoort er niet bij.

$prefix herkent die uberhaupt niet, USER_TABLE is hem ook vreemd. Je moet even die dingen vervangen door hun juiste waarde.
Daar was ik bang voor, want nu snap ike het echt niet meer.

Geplaatst: 09 feb 2006, 00:32
door XP-Rene
Klik eens op de link in mijn signature, en dan bedoel ik de van SQL leren?
Afijn, hier heb je hem direct: http://www.semeleer.nl/tut_sql.html
Daar wordt je vast wel wijzer van. Succes :thumb:

Geplaatst: 09 feb 2006, 10:08
door The Sting
XP-Rene schreef:Klik eens op de link in mijn signature, en dan bedoel ik de van SQL leren?
Afijn, hier heb je hem direct: http://www.semeleer.nl/tut_sql.html
Daar wordt je vast wel wijzer van. Succes :thumb:
Bedankt :thumb: