Unsupported operand types

Unsupported operand types

am 13.05.2005 03:42:04 von DJ Craig

I keep getting this error:
Fatal error: Unsupported operand types in
/usr/local/etc/httpd/htdocs/djtricities/kat/bpmchart/chart.p hp on line
58

I've looked for hours for some type of error, and tried lots of
different things, but I can't get it to work. I did a google search
for "unsupported operand types" and for most of the people getting this
error, it was something to do with the version of PHP that they were
running, but I can't change that because it's a shared server from a
hosting company. I'm using PHP version 4.3.11 on Linux. Heres the
program around line 58:
_________________________________
function makeTable($myarray){
$result = "";
for($row = 0; $row < count($myarray); $row++){
$result .= '';
for($col = 0; $col < count($myarray[$row]); $col++){
$result .= '' . $myarray[$row][$column] . '';
}
$result .= '';
}
return $result;
}

function bpm($cue, $play){
//if( abs($play - 2 * $cue) < abs($play - $cue) ) $cue = $cue * 2;
//else if( abs(2*$play - $cue) < abs($play -$cue) ) $play = $play *
2;
return ((-100 * ($cue - $play))/$cue); // ***LINE 58***
}
?>

Re: Unsupported operand types

am 13.05.2005 05:47:49 von Jerry Stuckle

DJ Craig wrote:
> I keep getting this error:
> Fatal error: Unsupported operand types in
> /usr/local/etc/httpd/htdocs/djtricities/kat/bpmchart/chart.p hp on line
> 58
>
> I've looked for hours for some type of error, and tried lots of
> different things, but I can't get it to work. I did a google search
> for "unsupported operand types" and for most of the people getting this
> error, it was something to do with the version of PHP that they were
> running, but I can't change that because it's a shared server from a
> hosting company. I'm using PHP version 4.3.11 on Linux. Heres the
> program around line 58:
> _________________________________
> function makeTable($myarray){
> $result = "";
> for($row = 0; $row < count($myarray); $row++){
> $result .= '';
> for($col = 0; $col < count($myarray[$row]); $col++){
> $result .= '' . $myarray[$row][$column] . '';
> }
> $result .= '';
> }
> return $result;
> }
>
> function bpm($cue, $play){
> //if( abs($play - 2 * $cue) < abs($play - $cue) ) $cue = $cue * 2;
> //else if( abs(2*$play - $cue) < abs($play -$cue) ) $play = $play *
> 2;
> return ((-100 * ($cue - $play))/$cue); // ***LINE 58***
> }
> ?>
>
>

What's actually in $cue and $play? Try echoing them to see. I suspect
one or both is not numeric.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: Unsupported operand types

am 13.05.2005 16:27:31 von lesperancer

shouldn't this
$result .= '' . $myarray[$row][$column] . '';
be
$result .= '' . $myarray[$row][$col] . '';

and I assume $cue is not zero
and then both $cue and $play are numerics

what's the code that calls this bpm() function look like ?

DJ Craig wrote:
> I keep getting this error:
> Fatal error: Unsupported operand types in
> /usr/local/etc/httpd/htdocs/djtricities/kat/bpmchart/chart.p hp on
line
> 58
>
> I've looked for hours for some type of error, and tried lots of
> different things, but I can't get it to work. I did a google search
> for "unsupported operand types" and for most of the people getting
this
> error, it was something to do with the version of PHP that they were
> running, but I can't change that because it's a shared server from a
> hosting company. I'm using PHP version 4.3.11 on Linux. Heres the
> program around line 58:
> _________________________________
> function makeTable($myarray){
> $result = "";
> for($row = 0; $row < count($myarray); $row++){
> $result .= '';
> for($col = 0; $col < count($myarray[$row]); $col++){
> $result .= '' . $myarray[$row][$column] . '';
> }
> $result .= '';
> }
> return $result;
> }
>
> function bpm($cue, $play){
> //if( abs($play - 2 * $cue) < abs($play - $cue) ) $cue = $cue * 2;
> //else if( abs(2*$play - $cue) < abs($play -$cue) ) $play = $play *
> 2;
> return ((-100 * ($cue - $play))/$cue); // ***LINE 58***
> }
> ?>
>

Re: Unsupported operand types

am 13.05.2005 17:23:19 von DJ Craig

Thanks, you were right, I was passing the bpm() function arrays. But I
still can't figure out how they got to be arrays. I used the each()
function in a while loop. Heres the code that calls the function:
while($col = each($cols)){
$rowNum = 0;
while($row = each($rows)){
$result[$rowNum][$colNum] = bpm($row, $col); //$row and $col are both
arrays here for some reason...
echo $result[$rowNum][$colNum] . '-';
$rowNum++;
}
$colNum++;
}
echo '

' . makeTable($result) . '
';

Re: Unsupported operand types

am 13.05.2005 17:49:34 von Oli Filth

DJ Craig wrote:
> Thanks, you were right, I was passing the bpm() function arrays. But
I
> still can't figure out how they got to be arrays. I used the each()
> function in a while loop. Heres the code that calls the function:
> while($col = each($cols)){
> $rowNum = 0;
> while($row = each($rows)){
> $result[$rowNum][$colNum] = bpm($row, $col); //$row and $col are
both
> arrays here for some reason...
> echo $result[$rowNum][$colNum] . '-';
> $rowNum++;
> }
> $colNum++;
> }
> echo '

' . makeTable($result) . '
';

each() returns an array. See the PHP manual.

--
Oli

Re: Unsupported operand types

am 13.05.2005 18:00:14 von Ewoud Dronkert

On 13 May 2005 08:49:34 -0700, Oli Filth wrote:
>> while($col = each($cols)){
>
> each() returns an array. See the PHP manual.

Yeah, http://php.net/each or try http://php.net/foreach


--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/

Re: Unsupported operand types

am 13.05.2005 19:03:36 von DJ Craig

Thanks, I've got it working now :-)