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]
Link to comment
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.
Link to comment
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
Link to comment
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.
Link to comment
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();
Link to comment
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!!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.