Jump to content

Data Not Inserting Into Database First time


gaspower

Recommended Posts

Hello,

 

I have a site on my local server and I have a strange issue. When I create a new product through the site, all data is inserted into the database, except for one field. But if I go back into that page where I created the product, edit product again and fill in the missing data in that field it will save on the second try. What would cause the database to not accept data on the first save, but does on the second save of the product?

 

I did a mysql log, and below is the details. Not sure if that gives any information that will help solve this issue.

 

Thank you

 

111209 12:43:03 75 Connect user@localhost as anonymous on

75 Quit

111209 12:43:04 76 Connect database@localhost on

76 Init DB database

76 Query select configuration_key as cfgKey, configuration_value as cfgValue from configuration

76 Query select value from sessions where sesskey = '25101rbiah2jt45t85pjrfi852' and expiry > '13234 63384'

76 Query select configuration_group_id as cgID, configuration_group_title as cgTitle from configurat ion_group where visible = '1' order by sort_order

76 Query select * from customers_groups order by customers_group_id

76 Query select * from customers_groups order by customers_group_id

76 Query select * from customers_groups order by customers_group_id

76 Query select count(*) as total from sessions where sesskey = '25101rbiah2jt45t85pjrfi852'

76 Query update sessions set expiry = '1323464824', value = 'language|s:7:\"english\";languages_id|s :1:\"1\";admin|a:2:{s:2:\"id\";s:1:\"1\";s:8:\"username\";s:13:\"database\";}' where sesskey = '25101rbiah2jt45t85pjrf i852'

76 Quit

111209 12:43:05 77 Connect user@localhost as anonymous on

Link to comment
Share on other sites

Hello Fenway,

 

Thank you for the prompt reply. Yes, it only updates the field on the second insert from that edit page. Not sure if you are familiar with Oscommerce, that is the software I am using. On the product page, where you create the details of new product the you submit. You have to do this process twice for one particular field to get data to insert.

 

Thank you

 

 

Link to comment
Share on other sites

Hello,

 

Here is the complete file. Thank you

 

<?php
  require('includes/application_top.php');

?>
<!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>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<div id="popupcalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'template_top.php'); ?>
<!-- header_eof //-->


<?php
if (isset($_POST['Update']))
{
        $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id";
        $sppc_query = tep_db_query($sppc_query_raw);
        while( $sppc = tep_db_fetch_array( $sppc_query ) ) {

         if ($sppc["customers_group_name"] != "Retail"){
//$sppc['customers_group_id']
        $c = "CG_".$sppc['customers_group_id'];
        $tmp = $_POST[$c];
        if ($tmp != 0)
        {
        $p = (100-$_POST[$c])/100;
        tep_db_query("delete from products_groups where customers_group_id = ".$sppc['customers_group_id']);

        tep_db_query ("insert into products_groups select '". $sppc['customers_group_id'] ."' as customers_group_id, ( " . $p . " * p.products_price) as customers_group_price, p.products_id from products p");
        }  //if not 0
        }  //if not Retail
        }
}

?>
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
        <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
        </table></td>
<!-- body_text //-->
        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
                <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
                  <tr>
                        <td class="pageHeading"><?php echo "Special Pricing Discount Setup"; ?></td>
                        <td class="specialPrice" align="right"> </td>
                  </tr>
                </table></td>
          </tr>

          <tr>
                <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
                  <tr>
                        <td valign="top"><table border="0" width="100%" cellspacing="2" cellpadding="2">
                          <tr class="dataTableHeadingRow">
                                <td class="dataTableHeadingContent" align="left">
                                <?php
                                if (isset($_POST['Update']))
                                {
                                        echo "<center>Updated!</center>";
                                }
                                ?>
                                 </td>
                          </tr>
<?php

        $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id";
        $sppc_query = tep_db_query($sppc_query_raw);
        while( $sppc = tep_db_fetch_array( $sppc_query ) ) {
?>
                          <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">
                                 <td class="dataTableContent" align="left">
                                  <?php
                                  if ($sppc["customers_group_name"] != "Retail"){
                                          echo $sppc["customers_group_name"];
                                  }
                                  if (isset($_POST['Update']))
                                  {
                                                if ($sppc["customers_group_name"] != "Retail"){
                                                $c = "CG_".$sppc['customers_group_id'];
                                                $tmp = $_POST[$c];
                                                echo " Current Discount is $tmp%" ;

                                                }
                                  }
                                  ?>

                                  </td>
                          </tr>
<?php
         }
?>
                </table></td>
          </tr>
          <tr>
           <td valign="top">
           <form action="" method="post">
                <table border="0" width="40%" cellspacing="0" cellpadding="2">
                          <tr>
                                <td class="smallText" align="left"> </td>
                                <td> </td>
                          </tr>
<?php
        $sppc_query_raw = "select * from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id";
        $sppc_query = tep_db_query($sppc_query_raw);
        while( $sppc = tep_db_fetch_array( $sppc_query ) ) {

        if ($sppc["customers_group_name"] != "Retail"){
?>
                          <tr>
                                <td class="smallText" align="left">Set New Percentage (%) Discount for <?=$sppc["customers_group_name"]?> :</td>
                                <td><input name="CG_<?=$sppc['customers_group_id']?>" type="text" size="5" value="0"></td>
                          </tr>
<?php
                          }
         }
?>
                          <tr>
                                <td colspan="2" align="center"><input type="submit" name="Update" value="Update"></td>
                          </tr>
                </table>
                </form>
           </td>
          </tr>
        </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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