Log in

View Full Version : Warning: rand() expects parameter 1



mysql
11-14-2011, 03:12 PM
Hi I am working on one of my sites but I have been having some problems with this one. I am getting this error below, I am actually getting the same error on 2 lines.

Warning: rand() expects parameter 1 to be long, string given in /home/content/07/7560507/html/hits/prepend.inc.php on line 99

I have included some of the code below to see if anyone can help me out. I have wrapped the selected line 99 in quote tags just so you can see I have the same error on line 101 as well.

$points_referer_view = $myrow2[17];

$refpoints = bcmul($myrow2[17],100,1);
$refpointsb = $refpoints / 10;
$refpointsc = bcmul($refpointsb,10,0);

$points_referer_jackpot_views = $myrow2[7];
$points_referer_jackpot_points = $myrow2[8];
$points_hit=1;
$points_register = $myrow2[6];

$points_banner_click = rand($zufc,$zufd);
$points_report = $myrow2[4];
$points_login = rand($zufa,$zufb);
$seitenname = $myrow2[1];
$emailadresse = $myrow2[2];
$seitenstart = $myrow2[19];
$tausch = $myrow2[20];

$url_index = $myrow2[0];
$url_logout_succesfull = $myrow2[15];
$url_register_succesfull = $myrow2[16];
$url_email_modified = $myrow2[14];
$url_default = $myrow2[13];

$banner_default_source = $myrow2[11];
$banner_default_target = $myrow2[12];
$banner_default_alt ='';

$showup_frequency = $myrow2[18];;
$showup_time = $myrow2[10];


If you want I could post code for the whole page in question but it is a lot of code 593 lines :)

mysql
11-14-2011, 03:53 PM
Hi, Think I have cracked it
This was my original line 99
$points_banner_click = rand($zufc,$zufd);

Now replaced with
$points_banner_click = rand(2, 3);

What I did was look at this part of the code earlier on

$result20 = mysql_query("SELECT za, zb, zc, zd FROM `demo_a_zahl`");
$myrow20 = mysql_fetch_row($result20);

$zufa = $myrow20[0];
$zufb = $myrow20[1];
$zufc = $myrow20[2];
$zufd = $myrow20[3];

Then I replaced
zufa with 0
zufb with 1
zufc with 2
zufd with 3

Unfortunately I am not very good with this yet so can not use the proper lingo but none the less it worked
I have just got to hope it does not ruin another part of what I have done.