Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.


Azyrus

Recommended Posts

Posted

Hello,

 

I have combined a few codes and come up with a automatic sliding carousel for the homepage that displays the specials.

(I'll release it as a contribution once its finished also.)

 

It currently works on all instances of oscommerce.

 

However in this instance it doesn't work I have one database with two shops connected to it. One shop works the other doesn't.

 

I receive this error. Both database.php are identical on each shop.

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in database.php on line 99

 

 

Lines 98-100 from database.php

 

 

function tep_db_fetch_array($db_query) {

return mysql_fetch_array($db_query, MYSQL_ASSOC);

}

 

Thank you for reading and help.

Posted

Hello multimixer, thank you so much for replying I really appreciate it your the first person to take a minute to help.

 

The code below I have used on multiple instances of oscommerce, all working except one which gives the "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in database.php on line 99"

error. Forgive me I am just starting to work with oscommerce can you see what is wrong with the tep_db_fetch_array? I don't understand why it works on one shop but not another =\. Thank you so much for your time.

 

 

 

<?php
$itemCountMax = 10 ;
if ( ! $manufacturerCarousel )
{
 $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added DESC";//$query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' desc limit " . $itemCountMax ) ;
}
// Products line format
//
$pline='<div class="pic_padd wrapper_pic_div" style="width:152px;height:152px;">
    <a class="prods_pic_bg" href="%s" style="width:152px;height:152px;"><img src="%s" alt="%s" title="%s"></a></div>
 <div class="box-padd">
  <div class="name name_padd  equal-height" style="min-height: 32px; "><div><span><a href="%s">%s</a><p>%s</p></span></div></div>
  <h2 class="price price_padd un"><b>Was: </b><span class="productSpecialPrice fl_left">%s</span></h2>
  <h2 class="price price_padd un"><b>Now: </b><span class="productSpecialPrice fl_left">%s</span></h2>
 </div>
</li><li class="li_carusel" style="overflow-x: hidden; overflow-y: hidden; float: left; width: 228px; height: 500px; ">
 <div class="extra_price"></div>
 ';
//   $pline = '<a href="%s" title="%s" rel="imagebox"><img src="%s" onMouseOver="javascript:display_comments(\'car%s\');" onMouseOut="javascript:remove_comments(\'car%s\');" border="0" /><br /><span style="visibility : hidden ; " id="car%s">%s<br/><S>%s</S> -%s</span></a>' ;
while( $query_result = tep_db_fetch_array($query) )
{
  {
   $carousel_image = DIR_WS_IMAGES . $query_result['products_image'] ;
   $link  = tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $query_result['products_id']) ;
   $image = DIR_WS_IMAGES . $query_result['products_image'] ;
   $id    = $query_result['products_id'] ;
   $name  = $query_result['products_name'] ;
   $price = $currencies->display_price($query_result['products_price'], tep_get_tax_rate($query_result['products_tax_class_id'])) ;
$desc = $query_result['products_description'] ;
   $sprice= $currencies->display_price($query_result['specials_new_products_price'], tep_get_tax_rate($query_result['products_tax_class_id'])) ;
  }
  // Prevents unavailable image file 
  //
  if ( ! file_exists($carousel_image) ) continue ;
   printf($pline, $link, $carousel_image, $name, $name, $link, $name, $desc, $price, $sprice, $sprice) ;
}
echo '</div>' ;
?>

Posted

Without taking a look into anything else you are doing there, the error is here

while( $query_result = tep_db_fetch_array($query) )

 

The input for your function is $query. From the code you posted, you have $query commented and use $special_query_raw. (why not directly using the tep_db_query function? Any reason?

 

Do following

 

1) Change your query to be like this, or in any case to anything you want to know from the database

$specials_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added DESC");

 

2) Use this "query name" as input for the function

while( $query_result = tep_db_fetch_array($specials_query) )

 

If the "name" you would use for the query would be $kuku_haha, then you would need to do tep_db_fetch_array($kuku_haha)

Archived

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

×
×
  • Create New...