Jump to content

ERROR: rand() expects parameter 2 to be long


koolheaven

Recommended Posts

Hey!!
Help needed!  ;)  :-[

I got this error:

PHP Warning:  rand() expects parameter 2 to be long, string given in /hermes/web06/b932/hy.agl01/captcha/class.captcha.php on line 78

PLEASE HELP ME!
those two files are attached with this post!!


Thanks in advance!


[attachment deleted by admin]
well i found the only "rand" thing in here.. i woulda looked for the line bu thad to use notepad.. anyway, this is what I get out of it

[b]rand(-$this->wordart['angle'],$this->wordart['angle'])[/b]

First let me make sure this is right. It looks like you want the first part to be negative since it has the "-" in front of it? I'm pretty sure you can't go by a negative number right there, it has to be 0 or up (i believe, don't quote me). and then, the 2nd number needs to be larger. You can't find a random number between 1 and 1. you have 2 of the same number there, it makes no sense.
[quote=PHP.Net]
If called without the optional min, max arguments rand()  returns a pseudo-random integer between 0 and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for example, use rand (5, 15).
[/quote]

Guess you can't use a negative number.  Other than that, you are supplying it with its 2 needed arguments. A start and a max
ok, erase that negative sign and make the 2nd number a BIGGER number, not the same number.

OLD:
[b]$imword->setTextAngle(rand(-$this->wordart['angle'],$this->wordart['angle']));[/b]

NEW:
[b]$imword->setTextAngle(rand($this->wordart['angle'],[i]BIGGER NUMBER[/i]));[/b]

Lets say $this->wordart['angle'] = 5
then the rand should be rand($this->wordart['angle'], SOMETHING GREATER THAN FIVE);

You see what i'm saying? And be sure that "-" gets out from infront of the first number.
[quote author=sasa link=topic=103486.msg412109#msg412109 date=1155078099]
the code is ok
you have Warning not error
posible: wordart['angle'] is NULL or 0
[/quote]

Still I got error. Here is the example how I add it!
(I'm new @ PHP)

function getWordArt($word) {
$imword = new WordArt($this->width,$this->height);
$imword->setFontDirectory($this->wordart['dir']);
$imword->setWord($word);
$imword->setCapital($this->wordart['capital']);
$imword->setTextAngle(rand($this->wordart['angle'],BIGGER NUMBER));
$this->wordart['angle'] = 5
rand($this->wordart['angle'], SOMETHING GREATER THAN FIVE);
$imword->setFontColor($this->wordart['color']);
$imword->drawText();
$imword->applyFilter($this->wordart['filter']);
return $imword->getWordArt();
[quote author=sasa link=topic=103486.msg412283#msg412283 date=1155107695]
try[code]
$this->wordart['angle'] = 5;
rand(-$this->wordart['angle'], $this->wordart['angle']);
[/code]
[/quote]

SASA, YOU ARE KOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOL
PROBLEM IS SOLVED!!!!!!!!!!!!
Without you, I couldnt solve this problem!
I wish I kiss you! lol!

Thanks a loooooooooooooooooooooooooooooooooooooooot!!!!!!!!!!

With LOTS of VIRTUAL LOVE n KISSES!!!!!!!!!!

Take Care,

Byeeeeeeeeee!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.