What could be the reason for this failure to insert a row ?
Here is my insert code: - $sql = "INSERT INTO `products` (live,cat_cd,long,user_id,prod_name,prod_desc_sht,prod_desc_lng)
-
VALUES
-
('$Db_live_cd','$Db_cat_cd','$Db_long_cd','{$_SESSION['expert']}','$Db_prod_name','$Db_prod_desc_sht','$Db_prod_desc_lng')";
-
-
echo "SQL: $sql";
-
-
$result = mysql_query($sql) or die("could not execute ADD a PRODUCT.". mysql_error());
-
This is my error message:
could not execute ADD a PRODUCT.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 'long,user_id,prod_name,prod_desc_sht,prod_desc_ln g) VALUES ('y','se','y',' at line 1
My table structure is here: -
$sql = "CREATE TABLE `products` (
-
`prod_id` int(4) NOT NULL AUTO_INCREMENT,
-
`confirm` char(1) NOT NULL default '',
-
`live` char(1) NOT NULL default '',
-
`type` char(1) NOT NULL default '',
-
`cat_cd` char(2) NOT NULL default '',
-
`long` char(1) NOT NULL default 'y',
-
`user_id` varchar(25) NOT NULL default '',
-
`prod_name` varchar(40) NOT NULL default '',
-
`prod_pict` varchar(25) NOT NULL default '',
-
`prod_desc_sht` text NOT NULL default '',
-
`prod_desc_lng` text NOT NULL default '',
-
`prod_link` varchar(50) NOT NULL default '',
-
`valid_fm_date` int(12) default NULL,
-
`valid_to_date` int(12) default NULL,
-
`vote_count` int(3) default '0',
-
`sales_count` int(3) default '0',
-
KEY `user_id` (`user_id`),
-
KEY `prod_id` (`prod_id`),
-
PRIMARY KEY (prod_name)
-
-
) ENGINE=MyISAM DEFAULT CHARSET=latin1";
-
I can not see any reason for the failure !!!
Any ideas ?
2 1895
Just found out that "long" is a reserved word so I'll change the field name.
Atli 5,058
Expert 4TB
Hi.
You can use reserved keywords as field/table/database names if you enclose them in back-ticks (as you do in the CREATE query).
But avoiding using them (at least by themselves) is still a good idea.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Martin |
last post by:
Hello,
I'm new with triggers and I can not find any good example on how to
do the following:
I have two tables WO and PM with the following fields:
WO.WONUM, VARCHAR(10)
WO.PMNUM,...
|
by: serge |
last post by:
I have a scenario where two tables are in a One-to-Many relationship
and I need to move the data from the Many table to the One table so
that it becomes a One-to-One relationship.
I need to...
|
by: Philip Boonzaaier |
last post by:
I want to be able to generate SQL statements that will go through a list of
data, effectively row by row, enquire on the database if this exists in the
selected table- If it exists, then the colums...
|
by: Bri |
last post by:
Greetings,
I'm having a very strange problem in an AC97 MDB with ODBC Linked tables
to SQL Server 7. The table has an Identity field and a Timestamp field.
The problem is that when a new record...
|
by: Carl |
last post by:
Hi,
I hope someone can share some of their professional advice and help me out
with my embarissing problem concerning an Access INSERT query. I have never
attempted to create a table with...
|
by: Chris Kratz |
last post by:
Hello all,
We have run into what appears to be a problem with rules and subselects in
postgres 7.4.1. We have boiled it down to the following test case. If
anyone has any thoughts as to why...
|
by: Lorenzino |
last post by:
Hi, I have a problem with bindings in a formview.
I have a formview; in the insert template i've created a wizard control and
inside
it i have an HTML table with some textboxes bound to the...
|
by: =?Utf-8?B?UmljaA==?= |
last post by:
On a form - I have a datagridview which is docked to the entire form. The
datagridview allows users to Delete and/or Add Rows. On the Form_Load event
I Fill the datagridview source table with a...
|
by: veasnamuch |
last post by:
I have a problem while I create a trigger to my table. My objective is getting any change made to my table and record it in to another table . My have thousands records before I add new trigger to...
|
by: =?Utf-8?B?RXJpYyBGYWxza2Vu?= |
last post by:
We’re storing our main entity in an insert only table which stores the
history of past revisions, but we’re facing problems with storing this
history as LINQ will only update the entity, and...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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...
|
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...
| |