coolapps Posted September 1, 2013 Share Posted September 1, 2013 Warning: Cannot use a scalar value as an array in /srv/disk10/1498077/www/stats.php on line 59 FILE: <?php session_start(); $_SESSION['sess_name'] = $$name; $_SESSION['sess_passwd'] = $$passwd; $_SESSION['sess_data'] = $$data; include("vars.php"); include("headfoot.php"); mysql_connect($db_host, $db_user, $db_pwd); mysql_select_db($db_name); uheader(); ?> <h4>Member Surfing Statistics</h4> <p>Below you will see the last 7 days of member credits earned, as well as, members websites shown. These statistics are automatically updated each time this page loads.</p> <?php $res = mysql_query("select distinct(date) from 7stat order by date desc limit 7"); if(mysql_num_rows($res)>0){ while ($r= mysql_fetch_row($res)) { $arr1u[]= $r[0]; } } $arr2 = array(); while (list($k, $v) = each($arr1u)) { $res = mysql_query("select sum(num) from 7stat where date='$v'"); $arr2[$v] = mysql_result($res, 0); } reset($arr2); while (list($k, $v) = each($arr2)) { $maxnum = $maxnum + $v; } $maxnum = round($maxnum); echo("<p><div style=\"padding-left: 10px\"><hr><br></div></p>"); echo("<p align=left><b>Credits Earned Last 7 Days:</b> <table width=100% style=\"padding-left: 10px;\">"); reset($arr2); while (list($k, $v) = each($arr2)) { $v = round($v); $px = 500 * ((($v * 100) / $maxnum) / 100); $px = round($px); echo("<tr><td width=10%><b>$k:</b></td><td align=left>$v Credits Earned</td></tr>"); } echo("<tr align=center><td colspan=2><font color=#0000ff><b>7 Day Earned Total:</font><br>$maxnum Credits Earned</b></td></tr></table></p>"); echo("<p><div style=\"padding-left: 10px\"><hr><br></div></p>"); $res = mysql_query("select distinct(date) from 7statsite order by date desc limit 7"); $sarr1u[] = $r[0]; if(mysql_num_rows($res)>0){ while ($r = mysql_fetch_row($res)) { $sarr1u[] = $r[0]; } } $sarr2 = array(); reset($sarr1u); while (list($k, $v) = each($sarr1u)) { $res = mysql_query("select sum(num) from 7statsite where date='$v'"); $sarr2[$v] = mysql_result($res, 0); } $maxnum[] = $r[0]; reset($sarr2); while (list($k, $v) = each($sarr2)) { $maxnum = $maxnum + $v; } $maxnum = round($maxnum); echo("<p align=left><b>Websites Shown Last 7 Days:</b> <table width=100% style=\"padding-left: 10px;\">"); reset($sarr2); while (list($k, $v) = each($sarr2)) { $v = round($v); $px = 500 * ((($v * 100) / $maxnum) / 100); $px = round($px); echo("<tr><td width=10%><b>$k:</b></td><td align=left>$v Websites Shown</td></tr>"); } echo("<tr align=center><td colspan=2><font color=#0000ff><b>7 Day Shown Total:</font><br>$maxnum Websites Shown</b></td></tr></table></p>"); ?> <?php ufooter(); mysql_close; exit; ?> Help me please! Quote Link to comment Share on other sites More sharing options...
.josh Posted September 1, 2013 Share Posted September 1, 2013 well i don't know what the intentions are, but basically up in line 49 you use $r to loop through database results, and the way the loop works is either $r gets some results (a numeric array of columns returnedfor the current row of results) or else (boolean) false. The loop doesn't end until $r gets a value of false. Then, down on line 59 you attempt to assign $r[0] to $maxnum[] well by that time, $r is false (a scalar, boolean value), not an array, so there is no $r[0] index. Quote Link to comment Share on other sites More sharing options...
coolapps Posted September 1, 2013 Author Share Posted September 1, 2013 thanks mate , but still get error! Quote Link to comment Share on other sites More sharing options...
.josh Posted September 1, 2013 Share Posted September 1, 2013 well what did you actually change? explain what you are attempting to do with that part of the code. Quote Link to comment Share on other sites More sharing options...
coolapps Posted September 1, 2013 Author Share Posted September 1, 2013 well what did you actually change? explain what you are attempting to do with that part of the code. I send you a PM Quote Link to comment Share on other sites More sharing options...
.josh Posted September 2, 2013 Share Posted September 2, 2013 and i ignored it. This is a free, public help site. If you want free help, it must be public. If you want me to respond to your PM and work with you specifically, that will cost you money. Quote Link to comment Share on other sites More sharing options...
coolapps Posted September 2, 2013 Author Share Posted September 2, 2013 ohh ok mate. This is the site where i get errors , please help me! http://texchange.co.nf/stats.php i'm new in php p.s sorry for my bad english Quote Link to comment 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.