Jump to content


Random Pic Block


  • You cannot reply to this topic
33 replies to this topic

#21 Gerry

    Advanced Member

  • Members
  • PipPipPip
  • 71 posts
  • Gender:Male
  • Location:St Helens - UK -

Posted 23 December 2006 - 04:00 PM

As I said this does not work and I keep getting the error I posted, I have tried this now on three seoerate boards and same error on all. Anyone help please.

#22 lucidservant

    Member

  • Members
  • PipPip
  • 22 posts

Posted 10 January 2007 - 08:09 AM

View Postchutieu, on Jan 1 2006, 11:27 PM, said:

try this code (not mine, can't recall who the author is) . Make sure you change the bold to reflect your site

<?php
echo('<CENTER><TABLE BORDER=0><TR>');
$MZresult = @mysql_query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
FROM `ibf_gallery_images` , `ibf_members`
WHERE ibf_gallery_images.member_id = ibf_members.id and ibf_gallery_images.approved=1
ORDER BY rand()
LIMIT 1");
while ( $MZrow = mysql_fetch_array($MZresult) ) {
echo('<TD ALIGN=CENTER width=99%><a href="../forum/index.php?act=module&module=gallery&cmd=si&img='.$MZrow['picid'].'">');
echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="../forum/uploads/');
echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>');
echo ('</TR><TR>');
}
echo('</TR></TABLE>');
?>


Thanks mate :-)

View PostGerry, on Dec 4 2006, 04:44 PM, said:

Would anyone have this for 2.2 please. This does not work.

Many thanks


Gerry, I have 2.2.1 and it works perfectly, check your edits. for your site, maybe permissions for folders where you store your images.. :)

#23 Proxykiller

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 15 January 2007 - 01:31 PM

View PostGerry, on Dec 9 2006, 03:18 PM, said:

Does not work for me, this is the error I get, anyone help please

IPB WARNING [2] mysql_fetch_array(): supplied argument is not a valid MySQL result resource (Line: 8 of /sources/action_public/uportal.php(859) : eval()'d code)



hello,
am gettting the similar error as shown above by gerry.. can anyone please help solve this.

thanks

#24 Green Ice Tea

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 19 February 2007 - 07:52 PM

^Getting the same error :(

#25 Green Ice Tea

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 19 February 2007 - 07:54 PM

Ok I usedthe code from chutieu and it works fine now! thanks

#26 Jean Teles

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 03 December 2007 - 01:32 PM

Hi, donīt work for me

Quote

IPB WARNING [2] mysql_fetch_array(): supplied argument is not a valid MySQL result resource (Line: 8 of /sources/action_public/uportal.php(859) : eval()'d code)


#27 lazywolfy

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 04 December 2007 - 03:00 PM

To show the pictures horizontally instead of vertically:
delete all instances of <TR> & </TR> (should be 2 each)

For Last 5 pics use idate DESC. For random pics use rand () <--These are parenthesis
* There's already a code for the randon pics I know, but that one doesn't allow you to click on the picture and it doesn't show the caption or name of the pic.


For multiple horizontal rows of images that includes Latest Pics and Random Pics:
(for example, one row of Latest 3 Images and 2nd row of Random 3 Images):
Everything in bold red below is editable

Quote

<?php
echo('<CENTER><TABLE BORDER=0>');
$MZresult = @mysql_query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
FROM `ibf_gallery_images` , `ibf_members`
WHERE ibf_gallery_images.member_id = ibf_members.id and ibf_gallery_images.approved=1
ORDER BY idate DESC
LIMIT 3");
while ( $MZrow = mysql_fetch_array($MZresult) ) {
echo('<TD ALIGN=CENTER width=99%><a href="../index.php?act=module&module=gallery&req=si&img='.$MZrow['picid'].'">');
echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="../gallery/');
echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>'); echo ('');
}
echo('</TABLE>');

?>
<?php
echo('<CENTER><TABLE BORDER=0>');
$MZresult = @mysql_query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
FROM `ibf_gallery_images` , `ibf_members`
WHERE ibf_gallery_images.member_id = ibf_members.id and ibf_gallery_images.approved=1
ORDER BY rand()
LIMIT 3");
while ( $MZrow = mysql_fetch_array($MZresult) ) {
echo('<TD ALIGN=CENTER width=99%><a href="../index.php?act=module&module=gallery&req=si&img='.$MZrow['picid'].'">');
echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="../gallery/');
echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>'); echo ('');
}
echo('</TABLE>');

?>
<a href="http://WWW.YOURFORUMWEBSITE.COM/index.php?act=module&module=gallery"><font size="2"><b>More Gallery Images Here</b></font></a>


#28 il saggio

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts

Posted 12 December 2007 - 07:00 AM

I do not have the ipb gallery ... but if you want to create a block that takes random of images from a folder with a certain size?

#29 pinguish

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 14 January 2008 - 05:25 AM

as the person who did the rather scrappy code at the start of this thread if you can't get it to work message me with a URL of you site and i can tell where you are going wrong.

#30 eyepuppy

    Newbie

  • Members
  • Pip
  • 7 posts

Posted 16 May 2008 - 06:51 PM

I am using IPB version 2.3.5 with IPB gallery 2.2 RC3 with Unreal Portal version 2.2.3. I got the same error, but mine was caused by a connection error. To solve this, I just recoded the connection. This is my code:

<?
	echo('<CENTER><TABLE BORDER=0><TR>');

	$MZresult = $this->ipsclass->DB->query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
	FROM `ibf_gallery_images` , `ibf_members`
	WHERE ibf_gallery_images.member_id = ibf_members.id
	ORDER BY rand()
	LIMIT 1");

	while ( $MZrow = $this->ipsclass->DB->fetch_row($MZresult)) {
		echo('<TD ALIGN=CENTER width=99%><a href="index.php?act=module&module=gallery&cmd=si&img='.$MZrow['picid'].'">');
		echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="uploads/');
		echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>');
		echo ('</TR><TR>');
	}
	echo('</TR></TABLE>');
?>


You shouldn't have to change anything, but if you still have issues, let me know.

#31 il saggio

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts

Posted 04 August 2008 - 03:32 AM

<div align="center">
<?
$imglist='';
//cartella di lettura delle immagini
$img_folder = "folder image";
mt_srand((double)microtime()*1000);
$imgs = dir($img_folder);
while ($file = $imgs->read()) {
//estensioni delle immagini
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
$imglist .= "$file ";
} closedir($imgs->handle);
$imglist = explode(" ", $imglist);
$no = sizeof($imglist)-2;
//scelta dell'immagine iniziale (0 č casuale)
$random = mt_rand(0, $no);
$image = $imglist[$random];
echo '<a href="link to image"><img src="'.$img_folder.$image.'" width="148" border=0></a>';
?>
</div>

without ipgallery
just replace your image folder path :)

#32 Steve

    Advanced Member

  • Administrators[Admin]
  • PipPipPip
  • 130 posts
  • Gender:Male

Posted 03 October 2008 - 10:04 PM

I have found a fault in the overall function of this code. It will display images from a private gallery as well. Any way to fox this?

<?php
echo('<CENTER><TABLE BORDER=0><TR>');
$MZresult = @mysql_query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
FROM `ibf_gallery_images` , `ibf_members`
WHERE ibf_gallery_images.member_id = ibf_members.id and ibf_gallery_images.approved=1
ORDER BY rand()
LIMIT 1");
while ( $MZrow = mysql_fetch_array($MZresult) ) {
echo('<TD ALIGN=CENTER width=99%><a href="../ipb/index.php?act=module&module=gallery&cmd=si&img='.$MZrow['picid'].'">');
echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="../ipb/uploads/');
echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>');
echo ('</TR><TR>');
}
echo('</TR></TABLE>');
?>


#33 dheyrman

    Advanced Member

  • Members
  • PipPipPip
  • 49 posts

Posted 30 January 2009 - 11:56 AM

View Posteyepuppy, on May 16 2008, 08:51 PM, said:

I am using IPB version 2.3.5 with IPB gallery 2.2 RC3 with Unreal Portal version 2.2.3. I got the same error, but mine was caused by a connection error. To solve this, I just recoded the connection. This is my code:

<?
	echo('<CENTER><TABLE BORDER=0><TR>');

	$MZresult = $this->ipsclass->DB->query("SELECT ibf_gallery_images.id as picid,ibf_members.name as mname,`masked_file_name`,`directory`,`caption`
	FROM `ibf_gallery_images` , `ibf_members`
	WHERE ibf_gallery_images.member_id = ibf_members.id
	ORDER BY rand()
	LIMIT 1");

	while ( $MZrow = $this->ipsclass->DB->fetch_row($MZresult)) {
		echo('<TD ALIGN=CENTER width=99%><a href="index.php?act=module&module=gallery&cmd=si&img='.$MZrow['picid'].'">');
		echo('<B>'.$MZrow['caption'].'</B><BR><IMG SRC="uploads/');
		echo($MZrow['directory']. '/tn_'.$MZrow['masked_file_name'].'" alt="click HERE more info on the image"'. 'border=0 ><BR>by '.$MZrow['mname'].'</TD>');
		echo ('</TR><TR>');
	}
	echo('</TR></TABLE>');
?>


You shouldn't have to change anything, but if you still have issues, let me know.



Works like a charm. works on 2.3.6 and gallery 2.2.4

and change the LIMIT 1 To 5 or more like you wish

Tank you.

#34 david morin

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 02 June 2010 - 11:33 AM

View PostGerry, on 09 December 2006 - 08:18 AM, said:

Does not work for me, this is the error I get, anyone help please

IPB WARNING [2] mysql_fetch_array(): supplied argument is not a valid MySQL result resource (Line: 8 of /sources/action_public/uportal.php(859) : eval()'d code)




I get this same error. . .

anyone know how to fix this?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users