haven't problem with the insert syntax...

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
Xplosion84
Forum Newbie
Posts: 9
Joined: Wed Jun 16, 2004 1:30 pm

haven't problem with the insert syntax...

Post by Xplosion84 »

Code: Select all

<?php
$add = "INSERT INTO products (ID, Cat_ID, Sub_Cat_ID, Product_Number, Product, Man_ID, Descriptions, In_Stock, Show_Quanity, Quanity, Cost, Sell_Price, Taxable, Tax_Price, Dementions, Weight) VALUES ('', '. $_POST['Category'] . ', ' . $_POST['Subcategory'] . ', ' . $_POST['Subcategory'] . ', ' . $_POST['ProductNumber'] . ', ' . $_POST['ProductName'] . ', ' . $_POST['Manufacturers'] . ', ' . $_POST['Descriptions'] . ', ' . $_POST['InStockCheck'] . ', ' . $_POST['ShowQCheck'] . ', ' . $_POST['Quanity'] . ', ' . $_POST['OurCost'] . ', ' . $_POST['SellPrice'] . ', ' . $_POST['TaxableCheck'] . ', ' . $_POST['TaxPrice'] . ', ' . $_POST['Dementions'] . ', ' . $_POST['WeightCheck'] . ')";
?>
I know that syntax is incorrect i'm not sure on how to get it to work.. Also my ID column is set to autimatically number so I'm not sure on what to do in the VALUES for that... it's the first line...

-peace
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

echo it out before inserting it and post that echo here
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

attempting to use the original would result in a few T_STRING error/warning/notices...

Code: Select all

<?php 
$add = "INSERT INTO products (ID, Cat_ID, Sub_Cat_ID, Product_Number, Product, Man_ID, Descriptions, In_Stock, Show_Quanity, Quanity, Cost, Sell_Price, Taxable, Tax_Price, Dementions, Weight) VALUES ('', '{$_POST['Category']}', '{$_POST['Subcategory']}', '{$_POST['Subcategory']}', '{$_POST['ProductNumber']}', '{$_POST['ProductName']}', '{$_POST['Manufacturers']}', '{$_POST['Descriptions']}', '{$_POST['InStockCheck']}', '{$_POST['ShowQCheck']}', '{$_POST['Quanity']}', '{$_POST['OurCost']}', '{$_POST['SellPrice']}', '{$_POST['TaxableCheck']}', '{$_POST['TaxPrice']}', '{$_POST['Dementions']}', '{$_POST['WeightCheck']}')"; 
?>
Last edited by feyd on Thu Jun 17, 2004 12:48 pm, edited 1 time in total.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Try:

Code: Select all

$add = "INSERT INTO products (Cat_ID, Sub_Cat_ID, Product_Number, Product, Man_ID, Descriptions, In_Stock, Show_Quanity, Quanity, Cost, Sell_Price, Taxable, Tax_Price, Dementions, Weight) VALUES ('{$_POST['Category']}', '{$_POST['Subcategory']}', '{$_POST['Subcategory']}', '{$_POST['ProductNumber']}', '{$_POST['ProductName']}', '{$_POST['Manufacturers']}', '{$_POST['Descriptions']}', '{$_POST['InStockCheck']}', '{$_POST['ShowQCheck']}', '{$_POST['Quanity']}', '{$_POST['OurCost']}', '{$_POST['SellPrice']}', '{$_POST['TaxableCheck']}', '{$_POST['TaxPrice']}', '{$_POST['Dementions']}', '{$_POST['WeightCheck']}')";
[edit] feyd beat me to it, took ages to type out as well!! ;)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

yeah.. took a bit of time to type..
Post Reply