Cannot use a scalar value as an array
| From: | Xavier Antoviaque | Date: | Tue, 04 Dec 2001 12:04:23 +0000 |
| Subject: | Cannot use a scalar value as an array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-76508@lists.php.net to get a copy of this message | ||
Hello all,
I have a problem with a php script, which I want to use to fetch two data
(integer) from a MySQL table, divide the first by the second, and store the
value resulting in an double array. That seems not very difficult, but I
always have the error 'Cannot use a scalar value as an array' when I use my
script.
Here it is :
$result = mysql_query("SELECT timestamp_c,connectes,num FROM
stats_serveurs WHERE timestamp_c LIKE '".$date."%' "AND
serveur='".
$serveur."'", $link);
$max = 0;
$reps = mysql_num_rows($result);
for($i = 1; $i<=$reps; $i++){
$row = mysql_fetch_row($result);
$serveur[$i]['heure'] = $row[0];
$serveur[$i]['connectes'] = (int) ($row[1] / $row[2]); // Error!
$max = max($max, $serveur[$i]['connectes']);
}
Any help is welcome ! :-)
--
Xavier.