Jump to content

[New Error]Warning: Cannot use a scalar value as an array in


coolapps

Recommended Posts

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!

 

Link to comment
Share on other sites

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.

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.