473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Going absolutely crazy...

1 New Member
Please help Can't take it anymore..I am new at this in school have assignment to insert info into database.

Error: INSERT INTO products( Product ID, Product Name, Description, Cost, Markup Percent, Refrigeration Needed, Brand, Year Introduced ) VALUES ('P0026', 'teabags', '24/case', '18', '50.00%','1' ,'Discount' ,'2008')

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ID, Product Name, Description, Cost, Markup Percent, Refrigeration Needed, Brand' at line 1
Code as follows:
if (isset ($_POST['submit']))
{
$id=$_POST['pid'];
$name=$_POST['pname'];
$desc=$_POST['pdesc'];
$cost=intval($_POST['pcost']);
$markup=$_POST['pmarkup'];
$fridge=($_POST['pfridge']== 'true') ? true:false;
$brand=$_POST['pbrand'];
$year=$_POST['pyear'];

$sql1="INSERT INTO products( Product ID, Product Name, Description, Cost, Markup Percent, Refrigeration Needed, Brand, Year Introduced ) VALUES ('{$id}', '{$name}', '{$desc}', '{$cost}', '{$markup}','{$fridge}' ,'{$brand}' ,'{$year}')";


$db->query($sql1);
}
Mar 14 '12 #1
1 1317
r035198x
13,262 MVP
You should only warp the value in single quotes if the column is a text type. Numeric types should not have their values wrapped in quotes.
Mar 14 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: doltharz | last post by:
Please Help me i'm doing something i though was to be REALLY EASY but it drives me crazy The complete code is at the end of the email (i mean newsgroup article), i always use Option...
4
by: Christopher | last post by:
This should be a quick one. URL: http://cfa-www.harvard.edu/~cpilman/Stuff/flush.html Code: ============================= <!DOCTYPE HTML Public "-//W3C//DTD HTML 4.01//EN">...
5
by: spoilsport | last post by:
Ive got to write a multi-function program and I'm plugging in the functions but I keep getting this error from line 40. Im new to this and cant find an answer anywhere. Sam #include...
3
by: Larry Tate | last post by:
I have had a monstrous time getting any good debugging info out of the .net platform. Using ... ..NET Framework 1.1 Windows 2K Server VB.NET <- is this the problem? error handling in the...
0
by: Shapper | last post by:
Hello, I have this code in Global.asax: Sub Session_Start(Sender As Object, E As EventArgs) Dim cookie As HttpCookie = Request.Cookies("MyCookie") If Not cookie Is Nothing Then...
1
by: Zack | last post by:
I am writing an app using FileSystemWatcher and just went a little class crazy. I have the following classes Server MasterServer inherits server SlaveServer inherits server SiblingServer...
1
by: Michiel | last post by:
Hello, I use Visual Studio .Net 2003 Professional (Trial version) on Windows XP Professional (Dutch version). I have a Windows Server 2003 with IIS 6 (UK version). There is no domain, just a...
6
by: thomas.luce | last post by:
Okay, I have been programming for a long time, and am getting back into C after about a 4 year break from it. Below is some code that won't compile for the life of me, and it is driving me crazy!...
0
by: eighthman11 | last post by:
Access 2000. Sql Server I know this is going to sound crazy but I have a continuous form which is bound to a sql table with an ODBC connection. I filter the records in the Continous form...
2
by: pedalpete | last post by:
Hi All, I'm using Bill Scott's YUI carousel v5.6, and I've run into a crazy looping javascript for some reason, and I can't seem to get around it. The carousel loads a bunch of items, 7 of...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.