Seite 1 von 1

Habe Schlimmes Problem! SQL

Verfasst: 02.01.2011 17:59
von laph
Hallo und guten Abend,
ich hab heute folgendes und grawirendes Problem gefunden. Ich weiß nicht, wie das passieren
konnte. Ich wollte auf das Profil von einem Freund klicken und bekomme stattdessen diese
Fehlermeldung:
Allgemeiner Fehler
SQL ERROR [ mysql4 ]

Tabelle 'usr_web553_3.phpbb_cwalkinsideprofile_views' existiert nicht [1146]

SQL

SELECT * FROM phpbb_cwalkinsideprofile_views WHERE profile_user_id = 85 AND viewer_user_id = 53

BACKTRACE

FILE: includes/db/mysql.php
LINE: 174
CALL: dbal_mysql->sql_error()

FILE: includes/functions_profileviews.php
LINE: 33
CALL: dbal_mysql->sql_query()

FILE: memberlist.php
LINE: 439
CALL: count_visit()


und leider weiß ich damit nichts anzufangen außer dass es von der Datenbank gelöscht wurde und ich weiß nicht warum das so ist.

Wie kann ich das wieder rückgängig machen,
Wie kann ich das Problem beheben,
Wie kann ich die fehlende Datei wiederherstellen?

ich würde mich um eine schnelle Rückantwort freuen!

mfg laph

Re: Habe Schlimmes Problem! SQL

Verfasst: 02.01.2011 18:07
von modernist
Die Suchfunktion scheint zwar allseits unbeliebt zu sein, hilft aber manchmal weiter (oder zur Not so Seiten wie google): https://www.phpbb.de/kb/sql_error :roll:

Re: Habe Schlimmes Problem! SQL

Verfasst: 02.01.2011 18:12
von laph
Ja sowas hab ich auch schon gefunden, aber leider nichts, dass mir weiterhelfen könnte.

Ich verstehe das ganze nicht.
also kann auch grad keinen bezug auf meine SQL ERROR finden.


kk ich hab das Problem gefunden, aber jetzt steht das wieder was neues...

Fatal error: Cannot redeclare count_visit() (previously declared in /var/www/web553/html/forum/includes/functions_profileviews.php:22) in /var/www/web553/html/forum/includes/functions_profileviews.php on line 22

Re: Habe Schlimmes Problem! SQL

Verfasst: 02.01.2011 18:18
von Mahony
Hallo
..aber leider nichts, dass mir weiterhelfen könnte
Na wie wäre es mal mit lesen und verstehen? :D

Dir fehlt der nötige Datenbank-Eintrag (also die Tabelle phpbb_cwalkinsideprofile_views).
Lösung: Die fehlende Tabelle anlegen (wie in der MOD install.xml angegeben).

Grüße: Mahony

Re: Habe Schlimmes Problem! SQL

Verfasst: 02.01.2011 18:20
von laph
kk ich hab das Problem gefunden, aber jetzt steht da wieder was neues...

Fatal error: Cannot redeclare count_visit() (previously declared in /var/www/web553/html/forum/includes/functions_profileviews.php:22) in /var/www/web553/html/forum/includes/functions_profileviews.php on line 22

Re: Habe Schlimmes Problem! SQL

Verfasst: 02.01.2011 18:32
von Mahony
Hallo
Überprüfe den Einbau des MODs noch einmal.

Grüße: Mahony

Re: Habe Schlimmes Problem! SQL

Verfasst: 02.01.2011 18:40
von laph

Code: Alles auswählen

<?php
/**
*
* @package phpBB3
* @version $Id: functions_profileviews.php 252 2009-11-23 20:51:27Z lefty74 $
* @copyright (c) 2008 lefty74
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

/**
* this  is the visit counter
**/
function count_visit($profile_user_id)
{
	global $config, $db, $user;

	$time = time();
	// Check whether the user viewing has already viewed the profile before
	$sql = 'SELECT *
		FROM ' . PROFILE_VIEWS_TABLE . "
		WHERE profile_user_id = " . (int) $profile_user_id . " 
		AND viewer_user_id = " . (int) $user->data['user_id'];

	$result = $db->sql_query($sql);

	if ( $row = $db->sql_fetchrow($result) )
	{
		if ( ($row['viewer_visit_time'] + $config['flood_profile_views']) < $time )
		{
			//user has viewed before so only update the time of last view and the counter
			$viewer_user_counter = $row['viewer_user_counter'] + 1;
			$sql_ary = array(
			'viewer_visit_time'		=> (int) $time,
			'viewer_user_counter'	=> (int) $viewer_user_counter
			);

			$sql = 'UPDATE ' . PROFILE_VIEWS_TABLE . '
				SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
				WHERE viewer_user_id = ' . (int) $user->data['user_id'] . '
				AND profile_user_id = ' . (int) $profile_user_id;
			$db->sql_query($sql);
		}
	}
	else
	{
		//first time the user views the profile so lets insert him into the database
		$sql_ary = array(
			'profile_user_id'		=> (int) $profile_user_id,
			'viewer_user_id'		=> (int) $user->data['user_id'],
			'viewer_visit_time'		=> (int) $time,
			'viewer_user_counter'	=> 1
		);

		$db->sql_query('INSERT INTO ' . PROFILE_VIEWS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));

	}
	$db->sql_freeresult($result);
}		
		
/**
* Generate the profile view list in the users profile
**/
function generate_profile_view_list($user_id)
{
	global $config, $db, $user;
	global $template, $phpbb_root_path, $phpEx;

	$profile_user_id_list = $total_profile_views = '';
	$profile_views = array();
	// generate the profile views list
	$user_id = (int) $user_id;
	$sql = 'SELECT p.*, u.user_id, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.username, u.user_colour
		FROM ' . PROFILE_VIEWS_TABLE . ' p, ' . USERS_TABLE. " u
		WHERE p.profile_user_id = $user_id
			AND p.viewer_user_id = u.user_id
		ORDER BY p.viewer_visit_time DESC";
	$result = $db->sql_query($sql);
	while ($row = $db->sql_fetchrow($result))
	{
		$profile_views[] = $row;
		$total_profile_views = $total_profile_views + $row['viewer_user_counter'];
	}
	$db->sql_freeresult($result);

	for ($i = 0, $end = (sizeof($profile_views) < $config['amount_profile_views']) ? sizeof($profile_views) : $config['amount_profile_views']; $i < $end; $i ++)
	{

		if ( $profile_views[$i]['user_id'] == ANONYMOUS)
		{
			$profile_views[$i]['username'] = $user->lang['GUEST'];
		}


		$avatar_max_dimensions = $avatar_width = $avatar_title = $avatar_height = $profile_views_avatar = '';
		$avatar_max_dimensions = (int) $config['pvavatar_max_dimensions']; 
		$avatar_title = sprintf($user->lang['PROFILE_VIEWS_AVA_TITLE'], $profile_views[$i]['username'], $user->format_date($profile_views[$i]['viewer_visit_time']));
		if ( !empty($profile_views[$i]['user_avatar']) )
		{

			if ( $profile_views[$i]['user_avatar_width'] >= $profile_views[$i]['user_avatar_height'] )
			{
				$avatar_width = ( $profile_views[$i]['user_avatar_width'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $profile_views[$i]['user_avatar_width'] ;
				$avatar_height = ( $avatar_width == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $profile_views[$i]['user_avatar_width'] * $profile_views[$i]['user_avatar_height']) : $profile_views[$i]['user_avatar_height'] ;
			}
			else
			{
				$avatar_height = ( $profile_views[$i]['user_avatar_height'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $profile_views[$i]['user_avatar_height'] ;
				$avatar_width = ( $avatar_height == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $profile_views[$i]['user_avatar_height'] * $profile_views[$i]['user_avatar_width']) : $profile_views[$i]['user_avatar_width'] ;
			}
			$profile_views_avatar = get_user_avatar($profile_views[$i]['user_avatar'], $profile_views[$i]['user_avatar_type'], $avatar_width, $avatar_height, $profile_views[$i]['username']);

		}
		else
		{
			$avatar_img = $phpbb_root_path . 'styles/' . $user->theme['imageset_path'] . '/theme/images/no_avatar.gif';
			$profile_views_avatar = '<img src="' . $avatar_img . '" width="' . $avatar_max_dimensions . '" title="' . $avatar_title . '" alt="' . $profile_views[$i]['username'] . '" height="' . $avatar_max_dimensions . '" />';
		}

		$profile_views_name = ( utf8_strlen($profile_views[$i]['username']) > 9 ) ? utf8_substr($profile_views[$i]['username'], 0, 6) . '...' : $profile_views[$i]['username'];

		$template->assign_block_vars('profile_views', array(
		'AVATAR'				=> ( $profile_views[$i]['viewer_user_id'] == ANONYMOUS ) ? $profile_views_avatar : '<a href="' . get_username_string('profile', $profile_views[$i]['user_id'], $profile_views[$i]['username'], $profile_views[$i]['user_colour']) . '" title="' . $avatar_title . '">' . $profile_views_avatar . '</a>',
		'PROFILE_VIEWS_LIST'	=> ( $profile_views[$i]['viewer_user_id'] == ANONYMOUS ) ? '<span title="' . $avatar_title . '" >' . $profile_views[$i]['username'] . '</span>' : '<span title="' . $avatar_title . '" >' . get_username_string('full', $profile_views[$i]['user_id'], $profile_views_name, $profile_views[$i]['user_colour']) . '</span>',
		));
	}
	$template->assign_vars(array(
	'S_PROFILE_VIEWS'		=> $config['display_profile_views'] ? true : false,
	'PROFILE_VIEWS'			=> $total_profile_views,
	'S_PROFILE_VIEW_ACTION'	=> append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=profile_views&u=' . $user_id),
	));
}

/**
* Obtain Profile Views Details
**/
function get_profile_views_details($profile_user_id)
{
	global $config, $db, $user, $auth;
	global $template, $phpbb_root_path, $phpEx;

	$start	= request_var('start', 0);
	$pv_default_key = 'c';
	$pv_sort_key = request_var('sk', $pv_default_key);
	$pv_sort_dir = request_var('sd', 'd');
	
	// Get user...
	$sql = 'SELECT *
		FROM ' . USERS_TABLE . '
		WHERE user_id = ' . (int) $profile_user_id;
	$result = $db->sql_query($sql);
	$pv_member = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);

	if (!$pv_member)
	{
		trigger_error('NO_USER');
	}

	$user_id = (int) $pv_member['user_id'];

	if ($config['load_onlinetrack'])
	{
		$sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline
			FROM ' . SESSIONS_TABLE . "
			WHERE session_user_id = $user_id";
		$result = $db->sql_query($sql);
		$row = $db->sql_fetchrow($result);
		$db->sql_freeresult($result);

		$pv_member['session_time'] = (isset($row['session_time'])) ? $row['session_time'] : 0;
		$pv_member['session_viewonline'] = (isset($row['session_viewonline'])) ? $row['session_viewonline'] :	0;
		unset($row);
	}

	$pf_member_avatar = get_user_avatar($pv_member['user_avatar'], $pv_member['user_avatar_type'], $pv_member['user_avatar_width'], $pv_member['user_avatar_height']);

	$template->assign_vars(show_profile($pv_member));

	$total_views = $total_viewers = $most_viewed = '';
	$sql = 'SELECT COUNT(viewer_user_id) AS total_viewers, SUM(viewer_user_counter) AS total_views, MAX(viewer_user_counter) as most_viewed
		FROM ' . PROFILE_VIEWS_TABLE . " 
		WHERE profile_user_id = " . $user_id;
	$result = $db->sql_query($sql);
	$row = $db->sql_fetchrow($result);
	$total_views = (int) $row['total_views'];
	$total_viewers = (int) $row['total_viewers'];
	$most_viewed = (int) $row['most_viewed'];
	$db->sql_freeresult($result);

	$viewers_per_page = (int) $config['amount_profile_views_detail']; 
	$avatar_max_dimensions = (int) $config['pvavatar_max_dimensions']; 
	
	// Sorting
	$pv_sort_key_sql = array('a' => 'u.username', 'b' => 'p.viewer_user_counter', 'c' => 'p.viewer_visit_time');

	$pv_order_by = '';

	// Sorting and order
	if (!isset($pv_sort_key_sql[$pv_sort_key]))
	{
		$pv_sort_key = $pv_default_key;
	}

	$pv_order_by .= ($pv_sort_key_sql[$pv_sort_key] == 'u.username') ? 'LOWER(' . $pv_sort_key_sql[$pv_sort_key] . ') ' . (($pv_sort_dir == 'a') ? 'ASC' : 'DESC') : $pv_sort_key_sql[$pv_sort_key] . ' ' . (($pv_sort_dir == 'a') ? 'ASC' : 'DESC');
	
	$pagination_url = append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=profile_views&u={$user_id}&sk={$pv_sort_key}&sd={$pv_sort_dir}");
	
	$sql_limit = min($viewers_per_page, max(1, $total_viewers - $start));

	$profile_user_id_list = $total_profile_views = '';
	$profile_views = array();

	// generate the profile views list
	$sql = 'SELECT p.*, u.*
		FROM ' . PROFILE_VIEWS_TABLE . ' p, ' . USERS_TABLE. " u
		WHERE p.profile_user_id = $user_id
		AND p.viewer_user_id = u.user_id
		ORDER BY $pv_order_by";
	$result = $db->sql_query_limit($sql, $sql_limit, $start);

	while ($row = $db->sql_fetchrow($result))
	{
		//in case someone enables guest view counting
		if ( $row['user_id'] == ANONYMOUS)
		{
			$row['username'] = $user->lang['GUEST'];
		}


		$avatar_width = $avatar_title = $avatar_height = $profile_views_avatar = '';

		if ( !empty($row['user_avatar']) )
		{
			if ( $row['user_avatar_width'] >= $row['user_avatar_height'] )
			{
				$avatar_width = ( $row['user_avatar_width'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['user_avatar_width'] ;
				$avatar_height = ( $avatar_width == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['user_avatar_width'] * $row['user_avatar_height']) : $row['user_avatar_height'] ;
			}
			else
			{
				$avatar_height = ( $row['user_avatar_height'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row['user_avatar_height'] ;
				$avatar_width = ( $avatar_height == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row['user_avatar_height'] * $row['user_avatar_width']) : $row['user_avatar_width'] ;
			}
			$profile_views_avatar = get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $avatar_width, $avatar_height, $row['username']);

		}
		else
		{
			$avatar_img = $phpbb_root_path . 'styles/' . $user->theme['imageset_path'] . '/theme/images/no_avatar.gif';
			$profile_views_avatar = '<img src="' . $avatar_img . '" width="' . $avatar_max_dimensions . '" title="' . $row['username'] . '" alt="' . $row['username'] . '" height="' . $avatar_max_dimensions . '" />';
		}


		if (!empty($row['user_allow_viewemail']) || $auth->acl_get('a_email'))
		{
			$email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $row['user_id']) : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $row['user_email']);
		}
		else
		{
			$email = '';
		}
		$pm = ($config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&mode=compose&u=' . $row['user_id']) : '';

		//in case someone enables guest view counting
		if ( $row['user_id'] == ANONYMOUS)
		{
			$email = '';
			$pm = '';
		}

		//obtain the avatar and username
		$template->assign_block_vars('profile_views', array(
			'USERNAME_CLEAN'	=> get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
			'U_PM'		=> $pm,
			'U_EMAIL'	=> $email,
			'LAST_VIEW'	=> $user->format_date($row['viewer_visit_time']),
			'VIEWS'		=> $row['viewer_user_counter'],
			'AVATAR'	=> ( $row['viewer_user_id'] == ANONYMOUS ) ? $profile_views_avatar : '<a href="' . get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']) . '" title="' . $row['username'] . '">' . $profile_views_avatar . '</a>',
	
			'USERNAME'	=> ( $row['viewer_user_id'] == ANONYMOUS ) ? $row['username'] : get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
		));
		
	}
	$db->sql_freeresult($result);

	$most_viewer = $most_viewer_avatar = $most_viewer_link = '';
	$sql = 'SELECT p.*, u.*
		FROM ' . PROFILE_VIEWS_TABLE . ' p, ' . USERS_TABLE. " u
		WHERE p.profile_user_id = $user_id
			AND p.viewer_user_counter = $most_viewed
			AND p.viewer_user_id = u.user_id
		ORDER BY p.viewer_user_counter DESC";
	$result = $db->sql_query_limit($sql, 1, 0);

	while ($row2 = $db->sql_fetchrow($result))
	{
		$avatar_width = $avatar_title = $avatar_height = $profile_views_avatar = $profile_url = '';
		
		if ( !empty($row2['user_avatar']) )
		{
			if ( $row2['user_avatar_width'] >= $row2['user_avatar_height'] )
			{
				$avatar_width = ( $row2['user_avatar_width'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row2['user_avatar_width'] ;
				$avatar_height = ( $avatar_width == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row2['user_avatar_width'] * $row2['user_avatar_height']) : $row2['user_avatar_height'] ;
			}
			else
			{
				$avatar_height = ( $row2['user_avatar_height'] > $avatar_max_dimensions ) ? $avatar_max_dimensions : $row2['user_avatar_height'] ;
				$avatar_width = ( $avatar_height == $avatar_max_dimensions ) ? round($avatar_max_dimensions / $row2['user_avatar_height'] * $row2['user_avatar_width']) : $row2['user_avatar_width'] ;
			}
			$most_viewer_avatar = get_user_avatar($row2['user_avatar'], $row2['user_avatar_type'], $avatar_width, $avatar_height, $row2['username']);
		}
		else
		{
			$avatar_img = $phpbb_root_path . 'styles/' . $user->theme['imageset_path'] . '/theme/images/no_avatar.gif';
			$most_viewer_avatar = '<img src="' . $avatar_img . '" width="' . $avatar_max_dimensions . '" title="' . $avatar_title . '" alt="' . $row2['username'] . '" height="' . $avatar_max_dimensions . '" />';
		}

		$most_viewer_link  = '<a href="' . get_username_string('profile', $row2['user_id'], $row2['username'], $row2['user_colour']) . '">' . $most_viewer_avatar . '</a>';
		
		
		if ( $row2['user_id'] == ANONYMOUS)
		{
			$most_viewer = $user->lang['GUEST'];
		}
		else
		{
			// If your style breaks due to long usernames, uncomment below line
			//$row2['username'] = ( utf8_strlen($row2['username']) > 12 ) ? utf8_substr($row2['username'], 0, 9) . '...' : $row2['username'];
			$most_viewer = get_username_string('full', $row2['user_id'], $row2['username'], $row2['user_colour']);
		}
 	
	}
	$db->sql_freeresult($result);

$template->assign_vars(array(
		'PROFILE_VIEWS'		=> $total_views,
		'PROFILE_VIEWERS'	=> $total_viewers,
		'RETURN_TO_PROFILE'	=> sprintf($user->lang['RETURN_PROFILE'], '<a href="' . get_username_string('profile', $pv_member['user_id'], $pv_member['username'], $pv_member['user_colour']) . '">', '</a>'),
		'MOST_VIEWED'		=> ($most_viewed) ? $most_viewed: '',
		'MOST_VIEWER'		=> ($most_viewer) ? $most_viewer : '',
		'VISITORS_PROFILE'	=> sprintf($user->lang['VISITORS_OF_PROFILE'], $pv_member['username']),
		'TITLE' 			=> sprintf($user->lang['PROFILE_VIEWS_OF'],$pv_member['username']),

		'U_SORT_PV_USERNAME'	=> append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=profile_views&u=' . $user_id . '&sk=a&sd=' . (($pv_sort_key == 'a' && $pv_sort_dir == 'a') ? 'd' : 'a')),
		'U_SORT_PV_VIEWS'		=> append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=profile_views&u=' . $user_id . '&sk=b&sd=' . (($pv_sort_key == 'b' && $pv_sort_dir == 'a') ? 'd' : 'a')),
		'U_SORT_PV_LAST_VIEW'	=> append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=profile_views&u=' . $user_id . '&sk=c&sd=' . (($pv_sort_key == 'c' && $pv_sort_dir == 'a') ? 'd' : 'a')),

		'PM_IMG'		=> $user->img('icon_contact_pm', $user->lang['SEND_PRIVATE_MESSAGE']),
		'EMAIL_IMG'		=> $user->img('icon_contact_email', $user->lang['EMAIL']),
		'AVATAR'		=> $most_viewer_link,
		'PAGINATION'    => generate_pagination($pagination_url, $total_viewers, $viewers_per_page, $start),
		'PAGE_NUMBER'   => on_page($total_viewers, $viewers_per_page, $start),
		'TOTAL_VIEWERS' => ($total_viewers == 1) ? $user->lang['PROFILE_VIEWER'] : sprintf($user->lang['PROFILE_VIEWERS'], $total_viewers)

	));
}

?>
function count_visit($profile_user_id)

aber ich weiß nicht was da falsch sein soll.

Re: Habe Schlimmes Problem! SQL

Verfasst: 02.01.2011 18:45
von Mahony
Hallo
Du sollst den Einbau des MODs noch einmal kontrollieren. Die Fehlermeldung besagt, dass eine Funktion (count_visit() ) mehrmals includiert wurde.


Grüße: Mahony

Re: Habe Schlimmes Problem! SQL

Verfasst: 02.01.2011 19:21
von laph
danke. ich habs gefunden!^^
omg ich hatte grad angst XD