On Tuesday, December 4, 2001, at 06:04 AM, Xavier Antoviaque wrote:
> > 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']); > } > How does the operator precedence work in the statement ($row[1] / $row[2]) ? You might try (($row[1]) / ($row[2])) instead, or pull those into scalar variables before trying the division. -Steve > Any help is welcome ! :-) > > -- > Xavier. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]