Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43259
Total Topics: 7518
Most Online Today: 201
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 199
Total: 199

Author Topic: Picture not selected when picture deleted  (Read 6378 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Picture not selected when picture deleted
« on: April 07, 2015, 07:30:14 am »
The error when accessing a picture that has been deleted states Picture not selected. Without changing the textstring, which is the easiest thing to do, how can I change it so that if the selected image ID is less than the last recorded ID, it states 'the image has been deleted', but if the ID is greater than the last recorded, it says 'Picture not selected'.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Picture not selected when picture deleted
« Reply #1 on: April 07, 2015, 08:48:59 am »
You can get the max image id from the smf_Gallery_pic table

SELECT MAX(ID_PICTURE) as maxid FROM smf_gallery_pic  and put that in the view picture function
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Picture not selected when picture deleted
« Reply #2 on: April 07, 2015, 08:59:31 am »
Hello,

I added this:

Code: [Select]
$result = db_query("
select
max(ID_PICTURE) as maxid
from {$db_prefix}gallery_pic", __FILE__, __LINE__);

at the top of the function smfGallery_viewPicture()

But I am not sure how to factor it into here:

Code: [Select]
// Get the picture ID
if(isset($_REQUEST['id']))
$id = (int) $_REQUEST['id'];
else
fatal_error($txt['gallery_error_no_pic_selected'],false);
« Last Edit: April 07, 2015, 09:02:35 am by shuban »

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Picture not selected when picture deleted
« Reply #3 on: April 07, 2015, 09:03:19 am »
$maxRow = mysql_fetch_assoc($result);

Code: [Select]

// Get the picture ID
if(isset($_REQUEST['id']))
{

   if ($id > $maxRow['maxid'])
    fatal_error($txt['gallery_error_no_pic_selected'],false);
   else
     fatal_error($txt['gallery_error_no_pic_selected'],false);


}
   else
      fatal_error($txt['gallery_error_no_pic_selected'],false);

Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Picture not selected when picture deleted
« Reply #4 on: April 07, 2015, 09:11:24 am »
Okay, an update. Here's what I did, but now every image, removed and still available shows with the error... :'(

Code: [Select]
function smfGallery_viewPicture()
{
global $context, $sourcedir, $db_prefix, $modSettings, $user_info, $func, $scripturl, $txt, $ID_MEMBER, $boardurl, $gallerySettings;

isAllowedTo('smfgallery_view');

$result = db_query("
select
max(ID_PICTURE) as maxid
from {$db_prefix}gallery_pic", __FILE__, __LINE__);
$maxRow = mysql_fetch_assoc($result);

$txt['gallery_error_picture_removed'] = 'The item has been permanently removed.';

// Get the picture ID
if(isset($_REQUEST['id']))
{
$id = (int) $_REQUEST['id'];

if ($id > $maxRow['maxid'])
fatal_error($txt['gallery_error_no_pic_selected'],false);
else
fatal_error($txt['gallery_error_picture_removed'],false);
}
   else
      fatal_error($txt['gallery_error_no_pic_selected'],false);

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Picture not selected when picture deleted
« Reply #5 on: April 07, 2015, 09:26:14 am »
That should do it...
I would print text after if ($id > $maxRow['maxid'])
And see if it reaches that point
And find out the value of id vs $maxRow['maxid']
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Picture not selected when picture deleted
« Reply #6 on: April 07, 2015, 09:32:25 am »
It is printing an array instead of a number :-\

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: Picture not selected when picture deleted
« Reply #7 on: April 07, 2015, 09:35:37 am »
Strange...not sure why that would happen......
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Picture not selected when picture deleted
« Reply #8 on: April 07, 2015, 09:59:52 am »
Here's what I did to make it work:

Code: [Select]
$maxid = db_query("
SELECT
MAX(ID_PICTURE) as maxid
FROM {$db_prefix}gallery_pic", __FILE__, __LINE__);
$maxidrow = mysql_fetch_assoc($maxid);

$dbresult = db_query("
SELECT
ID_PICTURE, USER_ID_CAT, ID_CAT
FROM {$db_prefix}gallery_pic
WHERE ID_PICTURE = $id  LIMIT 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($dbresult);
if (mysql_num_rows($dbresult) == 0)
{
if ($id > $maxidrow['maxid'])
fatal_error($txt['gallery_error_no_pic_selected'],false);
else
fatal_error($txt['gallery_error_picture_removed'],false);
}

Thanks, SMFHacks.

 

Related Topics

  Subject / Started by Replies Last post
4 Replies
5782 Views
Last post November 22, 2006, 03:05:58 pm
by tambitch
0 Replies
3715 Views
Last post December 07, 2010, 12:03:46 am
by marcbkk
1 Replies
4138 Views
Last post June 14, 2011, 11:36:38 pm
by SMFHacks
5 Replies
7027 Views
Last post June 24, 2012, 09:25:20 am
by shuban
0 Replies
3798 Views
Last post March 20, 2014, 04:12:32 pm
by Michel68

+- Recent Topics

No thumbnails on new uploads by SMFHacks
March 27, 2024, 02:10:41 pm

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Gallery icon as last added image by fvlog19
February 01, 2024, 01:04:56 pm

Powered by EzPortal