Seite 1 von 1

User Last Pic MOD - Apostroph im Username -> Probleme

Verfasst: 22.06.2008 09:39
von LOLRainbow
Hi, ich hab den User Last Pic in Profile MOD eingebaut. Der MOD funktioniert aber bei Usern, die ein Apostroph im Namen haben, nicht.
Could not obtain uploaded pics information

DEBUG MODE

SQL Error : 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 'Don' # AND pic_lock = 0 AND pic_approval = 1 ORDER BY pic_time DESC ' at line 1

SELECT pic_id, pic_title, pic_time, pic_desc FROM phpbb_album WHERE pic_username='El'Don' # AND pic_lock = 0 AND pic_approval = 1 ORDER BY pic_time DESC LIMIT 1

Line : 324
File : usercp_viewprofile.php
Wie muss ich den folgenden Code verändern, damit es keine Probleme mehr mit dem Apostroph gibt?

Code: Alles auswählen

// <!-- BEGIN Users Last Album Pic -->
   $sql = "SELECT pic_id, pic_title, pic_time, pic_desc FROM " . ALBUM_TABLE . " WHERE pic_username='".$profiledata['username']."'
#		AND pic_lock = 0 
		AND pic_approval = 1
		ORDER BY pic_time DESC
		LIMIT 1"; 
   if ( !($query_result = $db->sql_query($sql)) ) 
   { 
      message_die(GENERAL_ERROR, 'Could not obtain uploaded pics information', '', __LINE__, __FILE__, $sql); 
   } 
   $result = $db->sql_query($sql);
   $users_last_album_pic_id = '';
   $users_last_album_pic_title = '';
   $users_last_album_pic_desc = '';
   while ($row = $db->sql_fetchrow($result))
   {
	   $users_last_album_pic_id = $row['pic_id'];
	   $users_last_album_pic_title = $row['pic_title'];
	   $users_last_album_pic_desc = $row['pic_desc'];
	   $users_last_album_pic_time = $row['pic_time'];
   }

   If ( $users_last_album_pic_id )
   {
	   $users_last_album_pic = '<a href="album_showpage.php?pic_id=';
	   $users_last_album_pic .= $users_last_album_pic_id;
	   $users_last_album_pic .= '" target="_blank" class="postlink"><img style="border:solid 1px black; padding:0px;" src="album_thumbnail.php?pic_id=';
	   $users_last_album_pic .= $users_last_album_pic_id;
	   $users_last_album_pic .= '" alt="'.$users_last_album_pic_desc.'" title="'.$users_last_album_pic_desc.'" border="0" /></a>';
   }
   else
   {
	   $users_last_album_pic = '';
   }
// <!-- END Users Last Album Pic -->

Verfasst: 22.06.2008 09:54
von Balint
Hallo!

Du könntest versuchen, den Benutzernamen durch die phpBB-eigene Polierstation zu schicken

Ersetze

Code: Alles auswählen

   $sql = "SELECT pic_id, pic_title, pic_time, pic_desc FROM " . ALBUM_TABLE . " WHERE pic_username='".$profiledata['username']."' 
mit

Code: Alles auswählen

   $sql = "SELECT pic_id, pic_title, pic_time, pic_desc FROM " . ALBUM_TABLE . " WHERE pic_username='".phpbb_clean_username($profiledata['username'])."' 

Ungetestet allerdings...


Viele Grüße,
Bálint

Verfasst: 22.06.2008 11:50
von LOLRainbow
Cool, hat geklappt. Wusste garnicht das phpBB sowas hat/kann.

Danke, Timo