Jump to content

Archived

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

koolheaven

ERROR: rand() expects parameter 2 to be long

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Hey,
thanks. I have added
$imword->setTextAngle(rand(-$this->wordart['angle'],$this->wordart['angle']));


But still I get the same error!!!!!!!!!

Share this post


Link to post
Share on other sites
[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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
the code is ok
you have Warning not error
posible: wordart['angle'] is NULL or 0

Share this post


Link to post
Share on other sites
[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();

Share this post


Link to post
Share on other sites
try[code]
$this->wordart['angle'] = 5;
rand(-$this->wordart['angle'], $this->wordart['angle']);
[/code]

Share this post


Link to post
Share on other sites
[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!!

Share this post


Link to post
Share on other sites

×

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.