Jump to content


Photo

ERROR: rand() expects parameter 2 to be long


  • Please log in to reply
8 replies to this topic

#1 koolheaven

koolheaven
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 08 August 2006 - 09:07 PM

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]

#2 Jocka

Jocka
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationDallas, Texas

Posted 08 August 2006 - 10:15 PM

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

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

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.

#3 koolheaven

koolheaven
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 08 August 2006 - 10:25 PM

Hey,
thanks. I have added
$imword->setTextAngle(rand(-$this->wordart['angle'],$this->wordart['angle']));


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

#4 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 08 August 2006 - 10:30 PM

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).


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

#5 Jocka

Jocka
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationDallas, Texas

Posted 08 August 2006 - 10:31 PM

ok, erase that negative sign and make the 2nd number a BIGGER number, not the same number.

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

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

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.

#6 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 08 August 2006 - 11:01 PM

the code is ok
you have Warning not error
posible: wordart['angle'] is NULL or 0

#7 koolheaven

koolheaven
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 09 August 2006 - 12:20 AM

the code is ok
you have Warning not error
posible: wordart['angle'] is NULL or 0


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();

#8 sasa

sasa
  • Staff Alumni
  • Advanced Member
  • 2,804 posts
  • LocationHrvatska

Posted 09 August 2006 - 07:14 AM

try
$this->wordart['angle'] = 5;
rand(-$this->wordart['angle'], $this->wordart['angle']);


#9 koolheaven

koolheaven
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 09 August 2006 - 12:10 PM

try

$this->wordart['angle'] = 5;
rand(-$this->wordart['angle'], $this->wordart['angle']);


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!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users