Topics

User Functions

Events

There are no upcoming events

What's New

Stories

1 new Stories in the last 2 weeks

Comments last 2 weeks

No new comments

Trackbacks last 2 weeks

No new trackback comments

Links last 2 weeks

No recent new links

NEW FILES last 14 days

No new files

Welcome to Geeklog Saturday, May 25 2013 @ 06:11 AM EDT


 Forum Index > Extensions > PHP Blocks New Topic Post Reply
 PHP Blocks and 4images
   
rav
 02/19/03 11:52PM (Read 2429 times)  
+++--
Chatty

Status: offline


Registered: 01/14/03
Posts: 37
The geeklog & 4images integration worked perfectly, and I've been running it on my site since the day it was posted. I was wondering if anyone had any plans to do a "random photo block" for the 4images gallery. I've been poking around myself, but frankly, I'm still new to GL & PHP, and while eventually, I might be able to figure it out, I'm sure it would not be as good compared to most blocks/plugin's I've seen.

 
Profile Email
 Quote
nurseryboy
 02/20/03 08:31AM  
+++--
Chatty

Status: offline


Registered: 09/04/02
Posts: 43
Hello,

Yes, I have created a random image block for 4images. I have been using it on my site for a while, and it seems to be working just fine. You can download the code here. Just unzip, copy the code from the file into lib-custom, and create a block in GL that calls the new function.
That should be it Smile

 
Profile Email Website
 Quote
rav
 02/20/03 12:52PM  
+++--
Chatty

Status: offline


Registered: 01/14/03
Posts: 37
OMG, so awesome!

Thanks!!!

 
Profile Email
 Quote
nurseryboy
 02/20/03 07:23PM  
+++--
Chatty

Status: offline


Registered: 09/04/02
Posts: 43
No problem Smile

 
Profile Email Website
 Quote
rav
 02/20/03 09:50PM  
+++--
Chatty

Status: offline


Registered: 01/14/03
Posts: 37
That worked perfectly. Thank you very much!

After playing around with it for a few hours, I noticed that it didn't seem all that random (same photo kept coming back up, more often than not. I only have about 34 images currently, but the same image would load 9 out of 10 times.

I took a lil peek at your code, and read up on the rand() mysql fuction in an attempt to understand what you were doing.

I cam accross this:

<b>As of MySQL 3.23.52, MySQL changed the way
RAND() functions, such that you MUST supply a
SEED to get an actual random number. If you do
not, each new connection will return close to the
same number as the previous new connection. An
example to test this would be to run the follow
command multiple times in a row. mysql -u
username -p -e'select rand()' A basic way to seed
this would be to run RAND(NOW()).</b>

So I added the NOW() function to the RAND() and it totaly cured it for me. It seems much more random now, and I'm seeing images that were not showing up before.

Once again, thanks for the block, I know I couldn't have done it, but maybe this lil tweak will help others Smile


 
Profile Email
 Quote
nurseryboy
 02/21/03 08:54AM  
+++--
Chatty

Status: offline


Registered: 09/04/02
Posts: 43
Ok, cool. Thanks for finding that out. I will add it to the code right away.
I'm glad it is working fine for you too.
Have a great day!

 
Profile Email Website
 Quote
Anonymous: Anonymous
 03/10/03 07:00PM  



I like this block....
The RAND(NOW()) function did not work for me.
I kept getting the same image every time.
I found this in a post on mysql.com:
MD5(RAND())
This worked every time for me.
Hope this helps....

 
 Quote
Content generated in: 0.21 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to post 
Filtered HTML Allowed 
Censored Content