Jump to content

'Call to a member function on a non-object' help


cs1h

Recommended Posts

Hi, I am trying to get a star rating script working but I get the following error.

 

Fatal error: Call to a member function on a non-object in D:\Inetpub\vhosts\asfdhjfk.com\httpdocs\tester\rate.php on line 11

 

the code is,

 

<?php
include("DB.php");

mysql_connect($server, $db_user, $db_pass) 
or die ("Could not connect to mysql because ".mysql_error()); 

$id = $_GET['id'];
$title = '';

$sql = "SELECT name FROM movies WHERE movie_id=$id";
while( $sql->fetchInto( $row ) ) { $title = $row[0]; }
?>
<html>
<head>
<title><?php echo($title); ?></title>
<script src="prototype.js"></script>
<script>
function rate( value ) {
new Ajax.Updater( 'rating', 'ratemovie.php?id=<?php echo($id)?>&v='+value );
}
</script>
</head>
<body>
<h1><?php echo($title); ?></h1>

<div id="rating">
<img src="star_off.gif" onClick="rate(1)"></img>
<img src="star_off.gif" onClick="rate(2)"></img>
<img src="star_off.gif" onClick="rate(3)"></img>
<img src="star_off.gif" onClick="rate(4)"></img>
<img src="star_off.gif" onClick="rate(5)"></img>
<br/><br/>
<?php
$res2 = $db->query(
'SELECT count( rating ), sum(rating ) FROM ratings WHERE movie_id=?',
$id
);
while( $res2->fetchInto( $row ) )
{
?>
Votes: <?php echo($row[0]); ?><br/>
Average Rating: <?php echo($row[1]/$row[0]); ?>
<?php
}
?>
</div>

</body>
</html>

 

I don't know what to do about it. Can anyone help?

 

Thanks,

 

Colin

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.