Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Php problem

New Here ,
Apr 21, 2007 Apr 21, 2007
Hi!
I would like to ask about some solution for my problem.
I want to generate a number randomly but the number must not equal the ones in my database.
This is important couse if somebody upload a picture a number is generated, but how do i write the image path for the picture if i don't no what number's been generated?
Thank you in advance.
TOPICS
Server side applications
262
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 21, 2007 Apr 21, 2007
Jose 123 escreveu:
> Hi!
> I would like to ask about some solution for my problem.
> I want to generate a number randomly but the number must not equal the ones in
> my database.
> This is important couse if somebody upload a picture a number is generated,
> but how do i write the image path for the picture if i don't no what number's
> been generated?
> Thank you in advance.
>
Why not use "microtime"?

http://www.php.net/manual/en/function.microtime.php

http://www.educar.pro.br/a/dttime/index.php?pn=14&tr=17

http://www.educar.pro.br/a/dttime/index.php?pn=11&tr=17

http://www.educar.pro.br/a/math/index.php?pn=39&tr=41

--
zerof
http://www.educar.pro.br/
Apache - PHP - MySQL - Boolean Logics - Project Management
----------------------------------------------------------
Você deve, sempre, consultar uma segunda opinião!
----------------------------------------------------------
Deixe todos saberem se esta informação foi-lhe útil.
----------------------------------------------------------
You must hear, always, one second opinion! In all cases.
----------------------------------------------------------
Let the people know if this info was useful for you!
----------------------------------------------------------
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 21, 2007 Apr 21, 2007
And how should i use this? Sorry I don't speak spanish
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 21, 2007 Apr 21, 2007
LATEST
Jose 123 escreveu:
> And how should i use this? Sorry I don't speak spanish
hehehe.... this is portuguese, not spanish.

Try to use this code:

?php

$time = microtime();
$strsp = " "; // string delimiter.
list ($dt, $t) = explode( $strsp, $time );

/*
$dt -> variable assigned by the user to represent the fractionary
decimal part of $time

$t -> variable assigned for by user to represent the integer decimal
part of $time
*/

echo " \$t = " . $t . " s<br /><br />";
echo "\$dt = " . $dt . " s<br /><br />";

echo "\$t + \$dt = ";
echo $t + $dt . " s";

/*
For each new execution of this script, a bigger value than the previous
$time is generated.
You can use the integer decimal part ($t) to generate a new unique value
*/

?>
----------------
Ah... you can use too:

http://www.php.net/manual/en/function.uniqid.php
--
zerof
http://www.educar.pro.br/
Apache - PHP - MySQL - Boolean Logics - Project Management
----------------------------------------------------------
Você deve, sempre, consultar uma segunda opinião!
----------------------------------------------------------
Deixe todos saberem se esta informação foi-lhe útil.
----------------------------------------------------------
You must hear, always, one second opinion! In all cases.
----------------------------------------------------------
Let the people know if this info was useful for you!
----------------------------------------------------------
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines