error when trying to insert to mssql database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
sublimenal
Forum Newbie
Posts: 23
Joined: Sun May 16, 2004 2:17 pm
Location: Massachusetts

error when trying to insert to mssql database

Post by sublimenal »

Hi there,

I am converting cubecart into mssql from mysql but I ran into this roadblock.

When the script tries to insert

Code: Select all

INSERT INTO patrick_CubeCart_order_sum (cart_order_id, customer_id, email, name, add_1, add_2, town, county, postcode, country, phone, mobile, currency, name_d, add_1_d, add_2_d, town_d, county_d, postcode_d, country_d, subtotal, total_ship, total_tax, prod_total, shipMethod, ip, time, customer_comments, gateway) VALUES ('080310-183821-1682', '3655', 'pip@topnordic.com', ' Patrick Ipsen', 'Hovedvejen 176', '2 th.', 'Glostrup', ' ', '87687', 'Denmark', '72428626', ' ', '', ' Patrick Ipsen', 'Hovedvejen 176', '2 th.', 'Glostrup', ' ', '87687', 'Denmark', '190.00', '', '0.00', '190.00', 'Free Shipping', '75.130.110.48', '1205173291', '', 'Print_Order_Form')
 
I goet the error:
Warning: mssql_query(): message: Error converting data type varchar to numeric. (severity 16) in D:\websites\convert\classes\db.inc.php on line 204


My database schema is the following:

Code: Select all

 
-- Creating Table ""dbo.patrick_cubecart_order_sum""
CREATE TABLE dbo.patrick_cubecart_order_sum (
  cart_order_id      varchar(30) NOT NULL DEFAULT (''),
  customer_id        int NOT NULL DEFAULT ('0'),
  [name]             varchar(225) NOT NULL DEFAULT (''),
  add_1              varchar(225) NOT NULL DEFAULT (''),
  add_2              varchar(225) NOT NULL DEFAULT (''),
  town               varchar(225) NOT NULL DEFAULT (''),
  county             varchar(225) NOT NULL DEFAULT (''),
  postcode           varchar(225) NOT NULL DEFAULT (''),
  country            varchar(225) NOT NULL DEFAULT (''),
  name_d             varchar(225) NOT NULL DEFAULT (''),
  add_1_d            varchar(225) NOT NULL DEFAULT (''),
  add_2_d            varchar(225) NOT NULL DEFAULT (''),
  town_d             varchar(225) NOT NULL DEFAULT (''),
  county_d           varchar(225) NOT NULL DEFAULT (''),
  postcode_d         varchar(225) NOT NULL DEFAULT (''),
  country_d          varchar(225) NOT NULL DEFAULT (''),
  phone              varchar(225) NOT NULL DEFAULT (''),
  mobile             varchar(255),
  subtotal           decimal(30,2) NOT NULL DEFAULT ('0'),
  prod_total         decimal(30,2) NOT NULL DEFAULT ('0'),
  total_tax          decimal(30,2) NOT NULL DEFAULT ('0'),
  total_ship         decimal(30,2) NOT NULL DEFAULT ('0'),
  status             int NOT NULL DEFAULT ('1'),
  sec_order_id       varchar(30),
  ip                 varchar(20) NOT NULL DEFAULT (''),
  time               int NOT NULL DEFAULT ('0'),
  email              varchar(225) NOT NULL DEFAULT (''),
  comments           text,
  ship_date          varchar(50),
  shipMethod         varchar(255),
  gateway            varchar(50) NOT NULL DEFAULT (''),
  currency           varchar(5) NOT NULL DEFAULT (''),
  customer_comments  text,
  /* Keys */
  PRIMARY KEY (cart_order_id)
)
GO

Does anyone see the problem, Ive been staring at it for hours! lol
User avatar
HCBen
Forum Commoner
Posts: 33
Joined: Thu Jun 22, 2006 3:15 pm
Location: Indiana

Re: error when trying to insert to mssql database

Post by HCBen »

Try removing the single quotes from the all the numeric values to be inserted in INT and DECIMAL datatype columns.

So for example, the customer_id value should be 3655 instead of '3655' and empty values shouldn't contain single quotes either.

Also with your create table script, remove the single quotes from the default values for the INT or DECIMAL datatype columns.
Post Reply