Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help PLEASE - Average Rating display in product_info.php


Kohn

Recommended Posts

I am not a programmer. I was trying to add some features in the product_info.php (we are running on the 2002 March Oscommerce) and the following error occured:

 

1016 - Can't open file: 'sessions.MYI'. (errno: 145)

 

select value from sessions where sesskey = 'ed15a756b3086a6ab2a47d8af4f78626' and expiry > '1053302007'

 

[TEP STOP]

 

1016 - Can't open file: 'sessions.MYI'. (errno: 145)

 

select count(*) as total from sessions where sesskey = 'ed15a756b3086a6ab2a47d8af4f78626'

 

[TEP STOP]

 

I did a research in this forum and dropped the session table as indicated and the website was back online without a problem. However, another 5 hours later, the same problem occured. I am not sure if it's because of my code of my script that caused the problem since this problem related to sessions.MYI never happened before. I was wondering if somebody could debug the script below since I do not know if it's correctly programmed. Please help me out here. I really appreciate it. Our website is at www.audiocubes.com

 

<?php

$reviews = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "'");

$reviews_values = tep_db_fetch_array($reviews);

 

$reviews_average_query = tep_db_query("select (avg(reviews_rating) / 5 * 100) as average_rating from " . TABLE_REVIEWS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "'");

$reviews_average = tep_db_fetch_array($reviews_average_query);

 

if ($reviews_values['count'] == 0) {

echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'products_id=' . $HTTP_GET_VARS['products_id'], 'NONSSL') . '">Be the first one to write a review.</a><br>(<a href="http://www.audiocubes.com/promotion.php">Receive a free Audio CD-R for every review you write.</a>)';

} else if ($reviews_values['count'] > 0) {

 

echo TEXT_CURRENT_REVIEWS . ' ' . $reviews_values['count'] . '<br>';

 

echo TEXT_INFO_PRODUCTS_AVERAGE_RATING . ' <font color=orange>' . number_format($reviews_average['average_rating']). '% <img src="https://secure13.vosn.net/~audiocub/images/thumb.gif" valign=texttop>';

 

}

?>

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...