koolheaven Posted August 8, 2006 Share Posted August 8, 2006 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 78PLEASE HELP ME!those two files are attached with this post!!Thanks in advance![attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/16956-error-rand-expects-parameter-2-to-be-long/ Share on other sites More sharing options...
Jocka Posted August 8, 2006 Share Posted August 8, 2006 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 Link to comment https://forums.phpfreaks.com/topic/16956-error-rand-expects-parameter-2-to-be-long/#findComment-71445 Share on other sites More sharing options...
koolheaven Posted August 8, 2006 Author Share Posted August 8, 2006 Hey,thanks. I have added $imword->setTextAngle(rand(-$this->wordart['angle'],$this->wordart['angle']));But still I get the same error!!!!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/16956-error-rand-expects-parameter-2-to-be-long/#findComment-71453 Share on other sites More sharing options...
SharkBait Posted August 8, 2006 Share Posted August 8, 2006 [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 Quote Link to comment https://forums.phpfreaks.com/topic/16956-error-rand-expects-parameter-2-to-be-long/#findComment-71456 Share on other sites More sharing options...
Jocka Posted August 8, 2006 Share Posted August 8, 2006 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'] = 5then 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 Link to comment https://forums.phpfreaks.com/topic/16956-error-rand-expects-parameter-2-to-be-long/#findComment-71457 Share on other sites More sharing options...
sasa Posted August 8, 2006 Share Posted August 8, 2006 the code is okyou have Warning not errorposible: wordart['angle'] is NULL or 0 Quote Link to comment https://forums.phpfreaks.com/topic/16956-error-rand-expects-parameter-2-to-be-long/#findComment-71485 Share on other sites More sharing options...
koolheaven Posted August 9, 2006 Author Share Posted August 9, 2006 [quote author=sasa link=topic=103486.msg412109#msg412109 date=1155078099]the code is okyou have Warning not errorposible: 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 Link to comment https://forums.phpfreaks.com/topic/16956-error-rand-expects-parameter-2-to-be-long/#findComment-71516 Share on other sites More sharing options...
sasa Posted August 9, 2006 Share Posted August 9, 2006 try[code]$this->wordart['angle'] = 5;rand(-$this->wordart['angle'], $this->wordart['angle']);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16956-error-rand-expects-parameter-2-to-be-long/#findComment-71644 Share on other sites More sharing options...
koolheaven Posted August 9, 2006 Author Share Posted August 9, 2006 [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 KOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOLPROBLEM 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!! Quote Link to comment https://forums.phpfreaks.com/topic/16956-error-rand-expects-parameter-2-to-be-long/#findComment-71736 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.