MySQL Forums
Forum List  »  PHP

Help needed on how to check for errors
Posted by: John Oligario
Date: May 06, 2005 06:17PM

I need some help with a script, portions posted below, basically i have 40 boxes for part numbers to be keyed in and respective quantity boxes. What I need to do, is 'flag' the boxes with incorrect part numbers, while allowing the others to get posted to the order database.

I would appreciate any help with this. Again, this is partial code, if the rest is needed, let me know.

for ($i=1; $i<41; $i++) {
if (tep_not_null($directbuy_product[$i])){
$directbuy_query = tep_db_query("select products_id, products_model from " . TABLE_PRODUCTS . " where products_model = '" . $directbuy_product[$i] . "'");
if (!tep_db_num_rows($directbuy_query)) {
$directbuy_query = tep_db_query("select products_id, products_model from " . TABLE_PRODUCTS . " where products_model LIKE '%" . $directbuy_product[$i] . "%'");
}
if (tep_db_num_rows($directbuy_query) != 1) {
$error_str .= DIRECTBUY_ERROR_ONE . '<br>';
}
$directbuy = tep_db_fetch_array($directbuy_query);
if (tep_has_product_attributes($directbuy['products_id'])) {
$error_str .= DIRECTBUY_ERROR_TWO . '<br>';
} else {
$cart->add_cart($directbuy['products_id'], $cart->get_quantity($directbuy['products_id']) + $directbuy_qty[$i], false);
}
}
}

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

$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_DIRECTBUY));
?>
<!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_specials.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>
<tr>
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><?php echo TEXT_INFORMATION; ?></td>
</tr>
</table></td>
</tr>
<tr>
<td><br>
<form name="directbuy" method="post" action="<?php echo tep_href_link(FILENAME_DIRECTBUY,'action=directbuy');?>">
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td class="main"><?php echo DIRECTBUY_PRODUCT_ID; ?></td>
<td class="main"><?php echo DIRECTBUY_QUANTITY; ?></td>
<td class="main">&nbsp;</td>
<td class="main"><?php echo DIRECTBUY_PRODUCT_ID; ?></td>
<td class="main"><?php echo DIRECTBUY_QUANTITY; ?></td>
</tr>
<?php
for ($i=1; $i<41; $i++) {
?>
<tr>
<td class="main"><?php echo tep_draw_input_field('directbuy_product[' . $i . ']', ''); ?></td>
<td class="main"><?php echo tep_draw_input_field('directbuy_qty[' . $i . ']', '', 'size="1" maxlength="3"'); ?></td>
<td class="main">&nbsp;</td>
<?php $i++ ;?>
<td class="main"><?php echo tep_draw_input_field('directbuy_product[' . $i . ']', ''); ?></td>
<td class="main"><?php echo tep_draw_input_field('directbuy_qty[' . $i . ']', '', 'size="1" maxlength="3"'); ?></td>
</tr>
<?php }?>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif', '10', '10'); ?></td>
</tr>
</table>
</td>
</tr>

<tr>
<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
<tr class="infoBoxContents">
<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
<td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
</tr>
</table></form></td>
</tr>
</table></td>
</tr>
</table></td>

Options: ReplyQuote


Subject
Written By
Posted
Help needed on how to check for errors
May 06, 2005 06:17PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.