472,096 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,096 software developers and data experts.

Unsupported operand types

I keep getting this error:
Fatal error: Unsupported operand types in
/usr/local/etc/httpd/htdocs/djtricities/kat/bpmchart/chart.php 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 .= '<tr>';
for($col = 0; $col < count($myarray[$row]); $col++){
$result .= '<td>' . $myarray[$row][$column] . '</td>';
}
$result .= '</tr>';
}
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***
}
?>
</body></html>

Jul 17 '05 #1
6 34347
DJ Craig wrote:
I keep getting this error:
Fatal error: Unsupported operand types in
/usr/local/etc/httpd/htdocs/djtricities/kat/bpmchart/chart.php 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 .= '<tr>';
for($col = 0; $col < count($myarray[$row]); $col++){
$result .= '<td>' . $myarray[$row][$column] . '</td>';
}
$result .= '</tr>';
}
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***
}
?>
</body></html>


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.
js*******@attglobal.net
==================
Jul 17 '05 #2
shouldn't this
$result .= '<td>' . $myarray[$row][$column] . '</td>';
be
$result .= '<td>' . $myarray[$row][$col] . '</td>';

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.php 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 .= '<tr>';
for($col = 0; $col < count($myarray[$row]); $col++){
$result .= '<td>' . $myarray[$row][$column] . '</td>';
}
$result .= '</tr>';
}
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***
}
?>
</body></html>


Jul 17 '05 #3
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 '<table>' . makeTable($result) . '</table>';

Jul 17 '05 #4

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 '<table>' . makeTable($result) . '</table>';


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

--
Oli

Jul 17 '05 #5
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/
Jul 17 '05 #6
Thanks, I've got it working now :-)

Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Arpan | last post: by
1 post views Thread by Florian Lindner | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.