MindVerveMedia Posted February 4, 2007 Share Posted February 4, 2007 I'm getting the following error when I click "move" on the "OrderCheck -- Problem Orders" screen. 1292 - Incorrect datetime value: '' for column 'last_modified' at row 1 The problem occurs in admin\includes\functions\move_orders_check.php in these lines between the two debug echo statements: function straight_move($ocID, $dest_ocID='') { // ------------------------------------------------------------------------------------------ $orders_move_id = ($dest_ocID == '') ? $ocID : $dest_ocID; // ------------------------------------------------------------------------------------------ // TABLE_HOLDING_ORDERS >> TABLE_ORDERS $ORDERS_move_query = tep_db_query("select * from " . TABLE_HOLDING_ORDERS . " where orders_id = '" . $ocID . "'"); $ORDERS_move = tep_db_fetch_array($ORDERS_move_query); $ORDERS_move['orders_id'] = $orders_move_id; // BOF: debug echo "Before tep_db_perform(TABLE_ORDERS, \$ORDERS_move)\n"; // EOF: debug tep_db_perform(TABLE_ORDERS, $ORDERS_move); // BOF: debug echo "After tep_db_perform(TABLE_ORDERS, \$ORDERS_move)\n"; // EOF: debug Apparently, what is happening is that a NULL value for last_modified exists in the holding_orders table. How do I fix this statement so that the data will copy from one table to the other even if there is a NULL date, or NULL anything, for that matter? Is it something in the MySQL ini? This isn't the only place where I've had problems with NULL values or trying to use '' where NULL should be used. Quote Link to comment Share on other sites More sharing options...
MindVerveMedia Posted February 4, 2007 Author Share Posted February 4, 2007 The problem may be in tep_db_perform() itself. I added another debug statement before the call: function straight_move($ocID, $dest_ocID='') { // ------------------------------------------------------------------------------------------ $orders_move_id = ($dest_ocID == '') ? $ocID : $dest_ocID; // ------------------------------------------------------------------------------------------ // TABLE_HOLDING_ORDERS >> TABLE_ORDERS $ORDERS_move_query = tep_db_query("select * from " . TABLE_HOLDING_ORDERS . " where orders_id = '" . $ocID . "'"); $ORDERS_move = tep_db_fetch_array($ORDERS_move_query); $ORDERS_move['orders_id'] = $orders_move_id; echo "DEBUG: is_null(last_modified) " . is_null($ORDERS_move['last_modified']) . "<BR />"; echo "DEBUG: Before tep_db_perform(TABLE_ORDERS, \$ORDERS_move)<BR />"; tep_db_perform(TABLE_ORDERS, $ORDERS_move); echo "DEBUG: After tep_db_perform(TABLE_ORDERS, \$ORDERS_move)<BR />"; It returns true, so the value is properly set in $ORDERS_move['last_modified']. Quote Link to comment Share on other sites More sharing options...
MindVerveMedia Posted February 4, 2007 Author Share Posted February 4, 2007 I fixed the problem in tep_db_perform(). Here's what I did. It just needed a better check for NULL. function tep_db_perform($table, $data, $action = 'insert', $parameters = '', $link = 'db_link') { reset($data); if ($action == 'insert') { $query = 'insert into ' . $table . ' ('; while (list($columns, ) = each($data)) { $query .= $columns . ', '; } $query = substr($query, 0, -2) . ') values ('; reset($data); while (list(, $value) = each($data)) { // BOF: NULL check fix if (is_null($value)) { $query .= 'null, '; } else { // EOF: NULL check fix switch ((string)$value) { case 'now()': $query .= 'now(), '; break; case 'null': $query .= 'null, '; break; default: $query .= '\'' . tep_db_input($value) . '\', '; break; } // BOF: NULL check fix } // EOF: NULL check fix } $query = substr($query, 0, -2) . ')'; } elseif ($action == 'update') { $query = 'update ' . $table . ' set '; while (list($columns, $value) = each($data)) { switch ((string)$value) { case 'now()': $query .= $columns . ' = now(), '; break; case 'null': $query .= $columns .= ' = null, '; break; default: $query .= $columns . ' = \'' . tep_db_input($value) . '\', '; break; } } $query = substr($query, 0, -2) . ' where ' . $parameters; } return tep_db_query($query, $link); } Quote Link to comment Share on other sites More sharing options...
IndiaStarker Posted July 31, 2007 Share Posted July 31, 2007 THANKS MindVerveMedia, This fixed a problem I had. -i. Quote *** Je suis plus souvent sur le forum français *** ms2fr, Header Tags 2.5.5b, Order logging before payment, Better PayPal Description perso, Free shipping per product, Must agree to terms, Country State Selector, World Zones, Visible countries, Store Pick Up, several shipping modules, Personal Invoice Number, 'On the Fly' Auto Thumbnailer using GD Library, More_Pics_6 for 2.2 ms2, Ultimate SEO URLs 2-2.1d/e,Virement Bancaire, Estimated Shipping 1.5, xml_guide, SP+,Step By Step 1.8, Order Editor 2.6.3, Google Analytics, Dynamic Sitemap 2.0, OSC-Expeditor, Recover Cart Sales, Links Manager 1.15 local : linux 2.6 Fedora Core 3, server : APACHE 2.0.54, MySQL 4.1.18, php : 4.4.0 (on strike refuse to update) remote : IcoOpenBSD 4.x, server : IcodiaSecureHttpd, MySQL 4.1.24, php : 4.4.9 You never get a second chance to make a first impression. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.