Avatar billede beringshandel Nybegynder
14. april 2007 - 16:49 Der er 10 kommentarer

hvad er fejlen i dette script

min webmaster har kæmpet jeg ikke hvor mange timer med et auktionsmodul på min webshop, han fik det også op at køre, men det php scipts han har brugt er skrøbelig, forstået på den måde at nedtællingen ikke kommer til at passe med den oprindelige tid der er tilbage af auktionen.
det skal siges at min shop ligger på buydomains server i usa, så det er der taget højde for
Scriptet ser sådan ud:

<?php
/*
  $Id: auctions.php,v 1.4 2006/11/15 22:14:33 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

?>

<tr>
  <td>
    <table width="686">
      <tr>
        <td width="278"><!-- bof added by jobonline2001@yahoo.com for auction product contribution -->
<?php
  if ($auction_product) {
    $auction_query = tep_db_query("select auctions_starting_price, expires_date, overbid_amount from " . TABLE_AUCTIONS_PRODUCTS . " where products_id = '" . $product_info['products_id']. "' and status = '1' ");
    $auction_infor = tep_db_fetch_array($auction_query);
    $datetime_count_down = tep_date_count_down($auction_infor['expires_date']);
?>
          <table class="infoBox">
            <tr>
              <td width="239" class="infoBoxContents"><?php echo TEXT_AUCTION_PRICE . '&nbsp;' . $products_price; ?></td>
            </tr>
            <tr>
              <td class="infoBoxContents"><?php echo TEXT_EXPIRED_DATE . '&nbsp;' . $auction_infor['expires_date']; ?><br />(<b><span id="countdown_date" >&nbsp;</span></b>&nbsp;<?php echo TEXT_DATETIME_LEFT; ?>)</td>
            </tr>
            <tr>
              <td class="infoBoxContents"><?php echo TEXT_OVERBID_AMOUNT . '&nbsp;' . $currencies->display_price($auction_infor['overbid_amount'], tep_get_tax_rate($product_info['products_tax_class_id'])); ?></td>
            </tr>                           
          </table>
<?php
  } //end if
    else {
      echo $products_price;
  } // else if
?>
    <!-- eof added by jobonline2001@yahoo.com for auction product contribution -->
        </td>
        <td width="396"><!-- bof added by jobonline2001@yahoo.com for auction product contribution -->
<?php // If auction has expired
$mfo_auction_query = mysql_fetch_object(tep_db_query("select auctions_starting_price, expires_date, overbid_amount from " . TABLE_AUCTIONS_PRODUCTS . " where products_id = '" . $product_info['products_id']. "' and status = '1' "));
    if (strtotime($mfo_auction_query->expires_date)<time()) {
        echo tep_end_auction_valid();
    } elseif ( $auction_product ) { // Not sure, but probably similar to - If auction has not expired   
          echo tep_draw_form('auction_bid',tep_href_link(FILENAME_PRODUCT_INFO),'post', 'onsubmit="return check_agree(this);"');
?>
        <input type="hidden" name="placebid" value="true" id="placebid" />
        <input type="hidden" name="auction_id" id="auction_id" value="<?php echo $auction_id; ?>" />
        <input type="hidden" name="products_id" value="<?php echo (int)$HTTP_GET_VARS['products_id']; ?>" id="products_id" />
          <table>
            <tr>
              <td class="main" colspan="2"><?php echo TEXT_BID_PRICE . '&nbsp;' . tep_draw_input_field('bid_price', $bid_price);?></td>
            </tr>
           
            <tr>
              <td colspan="2"><input type="submit" value="Byd!"></td>
            </tr>
        </table></form>
        </td>
<?php
    }
?>             
<!-- eof added by jobonline2001@yahoo.com for auction product contribution -->
        </td>
      </tr>
    </table>
  </td>
</tr>
<tr>
  <td class="main"><b><?php echo TEXT_AUCTIONS_BID_LIST; ?></b></td>
</tr>
<tr>
  <td>
    <table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2" >
          <tr class="productListing-heading" >
            <td class="productListing-heading"><?php echo TABLE_HEADING_NUMBER; ?></td>
            <td class="productListing-heading"><?php echo TABLE_HEADING_CUSTOMERS; ?></td>
            <td class="productListing-heading" align="center"><?php echo TABLE_HEADING_BID_PRICE; ?>&nbsp;</td>
            <td class="productListing-heading"><?php echo TABLE_HEADING_BID_DATE_ADDED; ?></td>
            <td class="productListing-heading" align="center">&nbsp;</td>
          </tr>
<?php
  if (isset($HTTP_GET_VARS['page']) && ($HTTP_GET_VARS['page'] > 1)) $rows = $HTTP_GET_VARS['page'] * MAX_DISPLAY_SEARCH_RESULTS - MAX_DISPLAY_SEARCH_RESULTS;
  $products_query_raw = "select concat(c.customers_firstname, c.customers_lastname) as customers_name, c.customers_id, ab.bid_price, ab.bid_status, ab.bid_date_added from ".TABLE_CUSTOMERS." c, ".TABLE_AUCTIONS_BIDS.' ab,'.TABLE_AUCTIONS_PRODUCTS.' ap where c.customers_id = ab.customers_id and ab.auctions_id=ap.auctions_id and ab.auctions_id='.$auction_id.' order by bid_price DESC ';


  $rows = 0;
  $products_query = tep_db_query($products_query_raw);
  while ($products = tep_db_fetch_array($products_query)) {
    $rows++;

    if (strlen($rows) < 2) {
      $rows = '0' . $rows;
    }
?>
              <tr class="productListing-data" >
                <td class="productListing-data"><?php echo $rows; ?>.</td>
                <td class="productListing-data"><?php echo $products['customers_id']; ?></td>
                <td class="productListing-data" align="center"><?php echo $currencies->display_price($products['bid_price'], tep_get_tax_rate($products['products_tax_class_id']) ); ?>&nbsp;</td>
                <td class="productListing-data"><?php echo $products['bid_date_added']; ?></td>
                <td><?php if ($products['bid_status']=='won') { echo tep_image(DIR_WS_ICONS.'auctionwon.gif',IMAGE_BUTTON_AUCTION_WON); }?>
</td>
              </tr>
<?php
  }
?>
            </table></td>
          </tr>
       
        </table></td>
      </tr>

<SCRIPT type="text/javascript">

// ****  Time Zone Count Down Javascript  **** //
/*
Visit http://rainbow.arch.scriptmania.com/scripts/
for this script and many more
*/

////////// CONFIGURE THE COUNTDOWN SCRIPT HERE //////////////////

var month = '<? echo $datetime_count_down['1'];?>';    //  '*' for next month, '0' for this month or 1 through 12 for the month
var day = '<?php echo $datetime_count_down['3']; ?>';      //  Offset for day of month day or + day 
var hour = '0';        //  0 through 23 for the hours of the day
var tz = '+2';        //  Offset for your timezone in hours from UTC
var lab = 'countdown_date';    //  The id of the page entry where the timezone countdown is to show

function start() {displayTZCountDown(setTZCountDown(month,day,hour,tz),lab);}

    // **    The start function can be changed if required  **
window.onload = start();

////////// DO NOT EDIT PAST THIS LINE //////////////////

function setTZCountDown(month,day,hour,tz)
{
var toDate = new Date();
if (month == '*')toDate.setMonth(toDate.getMonth() + 1);
else if (month > 0)
{
if (month <= toDate.getMonth())toDate.setYear(toDate.getYear() + 1);
toDate.setMonth(month-1);
}
if (day.substr(0,1) == '+')
{var day1 = parseInt(day.substr(1));
toDate.setDate(toDate.getDate()+day1);
}
else{toDate.setDate(day);
}
toDate.setHours(hour);
toDate.setMinutes(0-(tz*60));
toDate.setSeconds(0);
var fromDate = new Date();
fromDate.setMinutes(fromDate.getMinutes() + fromDate.getTimezoneOffset());
var diffDate = new Date(0);
diffDate.setMilliseconds(toDate - fromDate);
return Math.floor(diffDate.valueOf()/1000);
}
function displayTZCountDown(countdown,tzcd)
{
if (countdown < 0) document.getElementById(tzcd).innerHTML = "Denne auktion er udløbet, kig ind igen for andre sjove auktioner :-)";
else {var secs = countdown % 60;
if (secs < 10) secs = '0'+secs;
var countdown1 = (countdown - secs) / 60;
var mins = countdown1 % 60;
if (mins < 10) mins = '0'+mins;
countdown1 = (countdown1 - mins) / 60;
var hours = countdown1 % 24;
var days = (countdown1 - hours) / 24;
document.getElementById(tzcd).innerHTML = days + " dag" + (days == 1 ? '' : 'e') + ' + ' +hours+ 'tim. : ' +mins+ 'min. : '+secs+'sek.';
setTimeout('displayTZCountDown('+(countdown-1)+',\''+tzcd+'\');',999);
}
}
</SCRIPT>

<!-- eof added by jobonline2001@yahoo.com for auction product contribution      -->
Avatar billede jakobdo Ekspert
15. april 2007 - 22:05 #1
Er du sikker på det er de rigtige info der bliver sat her:

////////// CONFIGURE THE COUNTDOWN SCRIPT HERE //////////////////

var month = '<? echo $datetime_count_down['1'];?>';    //  '*' for next month, '0' for this month or 1 through 12 for the month
var day = '<?php echo $datetime_count_down['3']; ?>';      //  Offset for day of month day or + day
var hour = '0';        //  0 through 23 for the hours of the day
var tz = '+2';        //  Offset for your timezone in hours from UTC
var lab = 'countdown_date';    //  The id of the page entry where the timezone countdown is to show
Avatar billede beringshandel Nybegynder
16. april 2007 - 06:19 #2
som sagt når man ikke selv kan php-sproget, det gør tingene lidt mere specialt, men jeg gjorde min webmaster opmærksom på nettop det område, men der havde han allerede rettet det til, nettop i det område, og nu køre nedtællingen som den skal.
men tak for dit svar, og efter selv at have snuset lidt til det (faktisk ret spænnene) så kan jeg godt se at det er noget der skal fagfolk til, da alt hænger sammen, forstået på den måde at ændre du et enkelt tegn, så kan det få betydning for hele systemmet, det gør det også i html, men slet ikke nær så følsom som php.
Avatar billede jakobdo Ekspert
16. april 2007 - 08:07 #3
Så det vil sige alt er som det skal være igen?
Avatar billede beringshandel Nybegynder
16. april 2007 - 08:25 #4
Jeg ved det ikke helt, jeg føler mig ikke sikker:
http://www.beringshandel.dk/shop/product_info.php?cPath=88&products_id=518
---------------------------------------------------------
Ændringen ser sådan ud nu:
////////// CONFIGURE THE COUNTDOWN SCRIPT HERE //////////////////

var month = '0';    //  '*' for next month, '0' for this month or 1 through 12 for the month
var day = '+<?php echo $datetime_count_down['2']; ?>';      //  Offset for day of month day or + day 
var hour = '0';        //  0 through 23 for the hours of the day
var tz = '2';        //  Offset for your timezone in hours from UTC
var lab = 'countdown_date';    //  The id of the page entry where the timezone countdown is to show

function start() {displayTZCountDown(setTZCountDown(month,day,hour,tz),lab);}

    // **    The start function can be changed if required  **
window.onload = start();
---------------------------------------------------------
Men nu brokker selve adminstrationsmodulet sig med denne fejlmeddelse:
Warning: Division by zero in /home/domains/beringshandel.dk/web/shop/admin/auctions.php on line 295
---------------------------------------------------------
Scriptet som den siger ikke stemmer overens mere ser sådan ud:

<?php
/*
  $Id: auctions.php,v 1.49 2003/06/09 22:35:33 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_AUCTIONS_PRODUCTS);

  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_AUCTIONS_PRODUCTS));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->
    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
            <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_auctions.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
  $auctions_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, a.auctions_starting_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_AUCTIONS_PRODUCTS . " a where p.products_status = '1' and a.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and a.status = '1' order by a.auctions_date_added DESC";
  $auctions_split = new splitPageResults($auctions_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);

  if (($auctions_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td class="smallText"><?php echo $auctions_split->display_count(TEXT_DISPLAY_NUMBER_OF_AUCTIONS); ?></td>
            <td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $auctions_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
  }
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
<?php
    $row = 0;
    $auctions_query = tep_db_query($auctions_split->sql_query);
    while ($auctions = tep_db_fetch_array($auctions_query)) {
      $row++;

      echo '            <td align="center" width="33%" class="smallText"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $auctions['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $auctions['products_image'], $auctions['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $auctions['products_id']) . '">' . $auctions['products_name'] . '</a><br>' .$currencies->display_price($auctions['auctions_starting_price'], tep_get_tax_rate($auctions['products_tax_class_id'])) . '</span></td>' . "\n";

      if ((($row / 3) == floor($row / 3))) {
?>
          </tr>
          <tr>
            <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
          </tr>
          <tr>
<?php
      }
    }
?>
          </tr>
        </table></td>
      </tr>
<?php
  if (($auctions_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>
      <tr>
        <td><br><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td class="smallText"><?php echo $auctions_split->display_count(TEXT_DISPLAY_NUMBER_OF_AUCTIONS); ?></td>
            <td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $auctions_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
          </tr>
        </table></td>
      </tr>
<?php
  }
?>
    </table></td>
<!-- body_text_eof //-->
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
    </table></td>
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
---------------------------------------------------------
Og den er der IKKE blevet ændret i, kan jeg se i ftp-programmet
Avatar billede beringshandel Nybegynder
16. april 2007 - 08:32 #5
Kan det skyldes at jeg har ændret den ordenære pris til nul, da efter jeg kan se ikke har noget med datoen men deriomod prisen i det scripts
Avatar billede jakobdo Ekspert
16. april 2007 - 08:51 #6
Men det er bestemt noget galt i koden:

Slutter den: 2007-04-17 00:00:00
(2 dage + 15tim. : 12min. : 37sek. tilbage)

Datoen på min computer er:
2007-04-16 08:48:00

Og her er også noget galt:

////////// CONFIGURE THE COUNTDOWN SCRIPT HERE //////////////////

var month = '0';    //  '*' for next month, '0' for this month or 1 through 12 for the month
var day = '+3';      //  Offset for day of month day or + day 
var hour = '0';        //  0 through 23 for the hours of the day
var tz = '2';        //  Offset for your timezone in hours from UTC
var lab = 'countdown_date';    //  The id of the page entry where the timezone countdown is to show

day + 3??
Avatar billede beringshandel Nybegynder
16. april 2007 - 09:25 #7
ja det er rigtigt, men hvis du kigger nede i venstre hjørne, så går den udfra den amerikanske servers dato og kl.
da jeg satte en "normalpris" på forsvant "warningen"
Avatar billede jakobdo Ekspert
16. april 2007 - 10:03 #8
kan der ikke være en fejl i denne kode:
<?php echo $datetime_count_down['2']; ?>
Nogle steder bruger du 3 og andre 2?

Prøv at udskrive indholdet af :

echo '<pre>';
print_r($datetime_count_down);
echo '</pre>';
Avatar billede beringshandel Nybegynder
16. april 2007 - 10:34 #9
Hej Jeg har lige fået denne mail fra webmaster, og han har ret i at det er en helhed sciptet skal ses i.:
---------------------------------------------------------
Hej Kim, scriptet er en kombination af PHP og Javascript.
PHP delen har eksperten.dk og dem der nu sidder og skriver dér, ikke nogen
forudsætninger for at bedømme - da der bliver brugt andre PHP funktioner -
som man ikke kan se ud af kode udsnittet du har indsat. Der er flere
filer, der bruges.. Det er nok også derfor de stiller spørgsmålstegn ved
hvad forskellige ting gør - da de ikke kan se det nogen steder.
---------------------------------------------------------
Så jeg tror vi lader den se om det kommer til at stemme nu, jeg skulle jo nødigt ødelægge hans arbejde.
men tak indtil vidre
mvh kim bering
Avatar billede jakobdo Ekspert
16. april 2007 - 10:48 #10
Men jeg synes jo den som beregner tid til udløb må have en fejl.
For +3 stemmer jo ikke som forskellen på 16 -> 17?
Det burde jo kun være +1.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester