As always, thanks for your help.
Gary
""Gary"" wrote in message
news:68.43.09009.cba46...@pb1.pair.com...
>A question was posted on another board that the poster wanted random flash
>movies to display as the page is reloaded. I posted the script below and
>said I thought it could be adapted
On Wed, March 21, 2007 5:40 pm, [EMAIL PROTECTED] wrote:
> Thanks. Yes, I check for errors. But there are other types of errors
> so I'd need to verify that it is a duplicate key error and, in my
> ignorance, I have not yet figured out how to do that programatically.
> I worry about getting into
abase engine that supports replication, since that's the only way to
ensure keys won't get repeated over multiple servers.
Satyam
- Original Message -
From: <[EMAIL PROTECTED]>
To:
Sent: Friday, March 23, 2007 7:48 PM
Subject: [PHP] Re: Random Unique ID
Robert C
Robert Cummings writes:
Bleh, you can solve this with at most 2 queries.
Thanks. That is a bit different than what I was thinking
about but it might work for my purposes. Thanks also to all
the other people who made suggestions.
It appears to me that ther are 3 distinct approaches.
1) Ge
[EMAIL PROTECTED] wrote:
> Hello,
>
> I want to add a random unique ID to a Mysql table. Collisions
> are unlikely but possible so to handle those cases I'd like to
> regenerate the random ID until there is no collision and only
> then add my row. Any suggestions for a newbie as to the right
>
Tijnema ! wrote:
> On 3/22/07, markw@mohawksoft.com wrote:
>> > On 3/22/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
>> >> # markw@mohawksoft.com / 2007-03-22 08:49:59 -0400:
>> >> > Tijnema ! wrote:
>> >> >
>> >> > > On 3/22/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
>> >> > >>
>> >> > >>
On 3/22/07, markw@mohawksoft.com wrote:
> On 3/22/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
>> # markw@mohawksoft.com / 2007-03-22 08:49:59 -0400:
>> > Tijnema ! wrote:
>> >
>> > > On 3/22/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
>> > >>
>> > >> http://www.ossp.org/pkg/lib/uuid
>> > >
> On 3/22/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
>> # markw@mohawksoft.com / 2007-03-22 08:49:59 -0400:
>> > Tijnema ! wrote:
>> >
>> > > On 3/22/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
>> > >>
>> > >> http://www.ossp.org/pkg/lib/uuid
>> > >
>> > > Note that this doesn't gonna work w
On 3/22/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
# markw@mohawksoft.com / 2007-03-22 08:49:59 -0400:
> Tijnema ! wrote:
>
> > On 3/22/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
> >>
> >> http://www.ossp.org/pkg/lib/uuid
> >
> > Note that this doesn't gonna work when safe mode is on..!
# markw@mohawksoft.com / 2007-03-22 08:49:59 -0400:
> Tijnema ! wrote:
>
> > On 3/22/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
> >>
> >> http://www.ossp.org/pkg/lib/uuid
> >
> > Note that this doesn't gonna work when safe mode is on..!
Ralf S. Engelschall's OSSP UUID library wrapped in a P
Tijnema ! wrote:
> On 3/22/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
>> # [EMAIL PROTECTED] / 2007-03-21 21:03:35 -0500:
>> > Mark wrote:
>> > >[EMAIL PROTECTED] wrote:
>> > >
>> > >>Hello,
>> > >>
>> > >>I want to add a random unique ID to a Mysql table. Collisions
>> > >>are unlikely but p
On 3/22/07, Roman Neuhauser <[EMAIL PROTECTED]> wrote:
# [EMAIL PROTECTED] / 2007-03-21 21:03:35 -0500:
> Mark wrote:
> >[EMAIL PROTECTED] wrote:
> >
> >>Hello,
> >>
> >>I want to add a random unique ID to a Mysql table. Collisions
> >>are unlikely but possible so to handle those cases I'd like
# [EMAIL PROTECTED] / 2007-03-21 21:03:35 -0500:
> Mark wrote:
> >[EMAIL PROTECTED] wrote:
> >
> >>Hello,
> >>
> >>I want to add a random unique ID to a Mysql table. Collisions
> >>are unlikely but possible so to handle those cases I'd like to
> >>regenerate the random ID until there is no collisi
On Thu, 2007-03-22 at 08:14 +0400, Rabih Tayyem wrote:
> Actually I told you that the possibility of collision is small because I
> wanted to be scientific
> Scientifically, I can say this posibilty goes to 0...
Only as the length of the ID approaches infinity :B
Cheers,
Rob.
--
.---
Actually I told you that the possibility of collision is small because I
wanted to be scientific
Scientifically, I can say this posibilty goes to 0...
It is a random ID (not a totally random but based on the current timestamp)
generated not only once but twice based on two different time s
Mark wrote:
[EMAIL PROTECTED] wrote:
Hello,
I want to add a random unique ID to a Mysql table. Collisions
are unlikely but possible so to handle those cases I'd like to
regenerate the random ID until there is no collision and only
then add my row. Any suggestions for a newbie as to the right
[EMAIL PROTECTED] wrote:
> Hello,
>
> I want to add a random unique ID to a Mysql table. Collisions
> are unlikely but possible so to handle those cases I'd like to
> regenerate the random ID until there is no collision and only
> then add my row. Any suggestions for a newbie as to the right
>
On Wed, 2007-03-21 at 16:40 -0600, [EMAIL PROTECTED] wrote:
> Jim Moseby writes:
>
> >> However, altho I know that by making the random number big enough
> >> the likelyhood of collisions can be made vanishingly small, I was
> >> actually concerned with eliminating the possibility of collisions
>
Jim Moseby writes:
However, altho I know that by making the random number big enough
the likelyhood of collisions can be made vanishingly small, I was
actually concerned with eliminating the possibility of collisions
altogether by checking to see if the number had been used before.
I just do
[EMAIL PROTECTED] wrote:
Stut writes:
[EMAIL PROTECTED] wrote:
I want to add a random unique ID to a Mysql table. Collisions
are unlikely but possible so to handle those cases I'd like to
regenerate the random ID until there is no collision and only
then add my row. Any suggestions for a newb
> Rabih Tayyem writes:
>
> > PS: I don't take credit for the code as it is a modified version of
> > a code I found long time back (this same code is running on one of
> > my applications for months without any problem)..
>
> Thanks. I'll find use for that!
>
> However, altho I know that by
Rabih Tayyem writes:
PS: I don't take credit for the code as it is a modified version of
a code I found long time back (this same code is running on one of
my applications for months without any problem)..
Thanks. I'll find use for that!
However, altho I know that by making the random num
Stut writes:
[EMAIL PROTECTED] wrote:
I want to add a random unique ID to a Mysql table. Collisions
are unlikely but possible so to handle those cases I'd like to
regenerate the random ID until there is no collision and only
then add my row. Any suggestions for a newbie as to the right
way to
[EMAIL PROTECTED] (Robb Kerr) writes:
> How's that for alliteration in a subject line?
Very nice! :-)
> [...] And, if this is the best way to go, unfortunately I don't
> know how to write a random number generator in PHP so would
> appreciate any help.
Your idea sounds good, and luckily you do
"Chris" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> $sql = "SELECT * FROM agentdb WHERE ((OfficeID <> 214) and
> (agentdb.agent_id<> 1115421) and (agentdb.agent_id > 100) and
> agentdb.agent_id <> 333)) ORDER BY RAND() LIMIT 1";
>
> The above code should generate a random
* Thus wrote Burrito Warrior ([EMAIL PROTECTED]):
>
> This would:
> /* selecting a random record, where n = 1. Works fine on small tables */
> mysql> SELECT value FROM table ORDER BY RAND() LIMIT n;
>
> /* selecting a random record. This is good on large tables if numbering
> sequence is used *
select all and
use
mysql_data_seek($result, rand(mysql_num_rows($result) - 1));
$row = mysql_fetch_assoc($result);
and there, your random row is returnd, that should be easy enough :) and it
should work
--
Luke
"Theheadsage" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hey,
>
>
CTED]
Subject: [PHP] Re: Random Numbers..
Theheadsage wrote:
> Hey,
>
> I've got a script which used to generate a random quote. It worked fine
> untill this problem occurred..
>
> Say we have 4 quotes with QuoteID's of 1 through to 4
> The script would grab a number
Theheadsage wrote:
Hey,
I've got a script which used to generate a random quote. It worked fine
untill this problem occurred..
Say we have 4 quotes with QuoteID's of 1 through to 4
The script would grab a number of rows, and generate a random number
between 1 and this value (being 4 in this case)
"Payne" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Hi,
>
> I am working on a project and I need to see sample quote for doing
> random quotes. These quotes will be put from a database. Can some please
> share me some sample code. Thanks.
>
> Chuck
For more solutions go to,
"Monil Chheda" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I want to create an php system that prevents automated
> registrations.
>
> I have come up with the script in which users come
> over and need to enter a random key displayed on the
> images while submitting their info. If
51 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Random numbers in a cronned script?
Yes, you're right about that point since the seed in most cases is computed
from system time => increasing probability of having same number @ the same
request time...
you can change the seed with the time()
Yes, you're right about that point since the seed in most cases is computed
from system time => increasing probability of having same number @ the same
request time...
you can change the seed with the time() too (not all days are the same).
hope to hear others' opinions too.
Elias
"Leif K-Brook
Hello,
On 08/18/2002 01:51 AM, César aracena wrote:
> Hi all. I know there must be several ways of doing this but I wonder
> what the best solution is. I'm tired of making and looking at scripts
> that creates random passwords for users from a "words.txt" list. These
> kind of passwords are limit
how about using the counter to store an id of the mirrors instead of
randomly picking one? this will provide you a sequential traverse
through all mirror sites.
if there are 10 sites, the counter will always be from 0 -> 9. this way
each mirror site will have equal share on hits. so if the cou
Seems good to me, only this part:
> and it will be checked if the mirror is randomly selected and
> if it is above 1200, will randomly select another server
It's better to select those under 1200 right from the start. If you have
10 servers, you might make 9 checks before selecting the last on
OOPS!
You are right on..
I noticed my error after I sent it. The name='guess' was on the input.??
Daaa! it's Monday .. OK!!
This should work:
===
The computer has picked $another number between 1 and 10.
Guess the number and you win!
Enter your gu
Try something like this and see if it works???
The computer has picked $another number between 1 and 10.
Guess the number and you win!
Enter your guess:
";
if (isset($guess))
{
srand((double)microtime()*100);
$number =
actually
if (intval($guess) == $number {
would be more acuate then the trim ( )
you would eliminate all alpha characters and floating points
saying it has to be a whole integer
Joel
"Ralph Friedman" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> In ar
In article <[EMAIL PROTECTED]>, Jennifer Downey wrote:
>
>
>
you've got the "Name" attribute attached to the wrong INPUT element:
> if($guess = = $number) {
>
incorrect syntax here. that should be:
if ($guess == $number) {
better would be:
if (trim($guess) == $number {
this will
You could store the results in a session var to carry along the pages.
Then on the second just retrieve them.
Or maybe a second table with this info. Give each search an ID and store
the results there. It would be easy to implement:
INSERT INTO table ('',field) SELECT field FROM table ORDER
yeah, my linux(Mandrake 8, Apache 1.3.22, PHP 4.1.0) box also gives me a 6 digit
integer each time too.
but when i tried on my win32 (Win2k, Apache 1.3.22, PHP 4.1.0), it is limited to a max
of 32767 as indicated with getrandmax(). the origional author of the problem probably
using windows to
On 19 Dec 2001, David wrote:
> should be because rand() can\'t generate such a large number for u.
>
> use $max_random_number = getrandmax(); to check
>
> http://sg.php.net/manual/en/function.getrandmax.php
Hmmm... My webserver gives me no problems witht this at all.
(Sun E250 with Solaris 8, A
should be because rand() can\'t generate such a large number for u.
use $max_random_number = getrandmax(); to check
http://sg.php.net/manual/en/function.getrandmax.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:
Got it...if anyone's interested the code is below :)
/connect to db
$connectionToDBid = odbc_connect("codesnipits", "joecode", "joecode");
// sql statement
$sqlb = "SELECT imagepath FROM IMAGES";
/ run the query and dump into $numberofrecords variable
$row = odbc_do($connectionToDBid, $sqlb);
$ceiling is too big.
try to do this and see:
echo getrandmax();
you might get 32767 as an output!
therefore, $ceiling must be <= getrandmax();
try to scale down your floor and ceiling,
ie:
$max = $ceiling - $floor;
$random = rand(0, $max) + $floor;
"Andrew Duck" <[EMAIL PROTECTED]> wrote in me
You should call mt_srand((double) microtime() * 100) once, and only
once, in any given script.
--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmus
[EMAIL PROTECTED] (Nikola Veber) wrote:
> Hi !
> I'm having troubles with the random numbers. When I create a number witm mt_rand()
> I always get the same number on my local server. I need this stuff to ranomly
>display
> some text, and I'd like to have another value of the random number
"Rosen" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
> I'm using PHP code from manual:
> srand( (double) microtime() * 100);
> // Get random User ID
> $uid=rand();
>
> but it dowsn't work !
... I would make sure that microtime() is doing what you th
>Could somebody please show me, send me an example or redirect me to a page
which shows how to >show a random FLASH movie from a text file which
contains different names of different movies >so that when i go on the page
it shows lets say, 1 of the 5 movies in the text document.
";
?>
There's a
50 matches
Mail list logo