Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 11809
Latest: Rheingauner
New This Month: 1
New This Week: 0
New Today: 0
Stats
Total Posts: 41673
Total Topics: 7283
Most Online Today: 40
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 57
Total: 57

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

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 662
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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: 15779
    • 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: 662
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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: 15779
    • 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: 662
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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: 15779
    • 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: 662
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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: 15779
    • 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: 662
    • View Profile
    • Homework Clinic - Your Academic Lifeline
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
5446 Views
Last post November 22, 2006, 03:05:58 pm
by tambitch
0 Replies
2514 Views
Last post December 07, 2010, 12:03:46 am
by marcbkk
1 Replies
2872 Views
Last post June 14, 2011, 11:36:38 pm
by SMFHacks
5 Replies
5072 Views
Last post June 24, 2012, 09:25:20 am
by shuban
0 Replies
2689 Views
Last post March 20, 2014, 04:12:32 pm
by Michel68

+- Recent Topics

Bulk Upload Many Pictures by SMFHacks
Today at 01:52:32 pm

8: Trying to access array offset on value of type null by SMFHacks
January 27, 2022, 10:27:28 pm

The download button has disappeared by SMFHacks
January 23, 2022, 07:32:43 am

Logo and Category? by tank_fv101
January 10, 2022, 08:03:11 am

Questions about SMF Gallery Pro Folders and Gallery URL by scso1502
January 05, 2022, 03:48:27 pm

$subcats_linktree by mickjav
January 05, 2022, 03:08:29 pm

New Photos Won't Upload - Gallery Pro 8.0 or 9.0b - Old Photos Still Visible by scso1502
January 05, 2022, 02:23:16 pm

Additional Recommendations for SMF Store by SMFHacks
January 03, 2022, 02:37:10 pm

Seasons Greetings by SMFHacks
December 24, 2021, 10:02:42 pm

Problems with the contact mod by SMFHacks
December 22, 2021, 09:16:24 am

Powered by EzPortal