473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Error on Insert on a Access Data Base

8
Hello,

I am having a problem that I can't seem to work out. I am running Apache 2.2 on a Windows XP platform, using PHP5. I am attempting to insert a row into a MS Access data base with a PHP script. I have a good connection into the data base, because select's work well.

The error that I am getting is:
Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 5., SQL state 07001 in SQLExecDirect in C:\xampp\htdocs\test.php on line 98 Error in SQL Insert statment please check code

from the statment:
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO problems (Issue_key, user, phone, issue, Issue_Date ) SELECT "Issue ID 1" AS Issue_Key, "steve" AS user, "7777" AS phone, "test information" AS issue, "10/30/2007" AS Issue_Date; 
Has anyone seen this error, and knows what the cause may be? I would appreciate any advice very much.

Thank You
Oct 30 '07 #1
8 3657
I don't use access too often but the last half of your query (SELECT "Issue ID 1" AS Issue_Key, "steve" AS user, "7777" AS phone, "test information" AS issue, "10/30/2007" AS Issue_Date) looks incomplete. Select from what table?
Oct 30 '07 #2
slb813
8
I don't use access too often but the last half of your query (SELECT "Issue ID 1" AS Issue_Key, "steve" AS user, "7777" AS phone, "test information" AS issue, "10/30/2007" AS Issue_Date) looks incomplete. Select from what table?
I don't work with access much either, this is a insert statment that I did with the GUI inside Access, then cut and pasted into the PHP code. When I cut the statment back into Access it works great with no error.
Oct 31 '07 #3
code green
1,726 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 5., 
This is usually because you are using a wrong field name
Oct 31 '07 #4
slb813
8
Expand|Select|Wrap|Line Numbers
  1. SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 5., 
This is usually because you are using a wrong field name
I checked and double checked the field names, then I can cut the insert statment and past it into a Access query inside Access and it works. This leads me to think that the field names are OK.

Thanks
Oct 31 '07 #5
code green
1,726 Expert 1GB
Required syntax varies between Access DB and Access query in PHP.
Try replacing the double quotes with square brackets where there is a field name space.
In fact why are the quotes there?

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO problems (Issue_key, user, phone, issue, Issue_Date ) SELECT [Issue ID 1] AS Issue_Key, "steve" AS user, "7777" AS phone, [test information] AS issue, "10/30/2007" AS Issue_Date;
Oct 31 '07 #6
slb813
8
Required syntax varies between Access DB and Access query in PHP.
Try replacing the double quotes with square brackets where there is a field name space.
In fact why are the quotes there?

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO problems (Issue_key, user, phone, issue, Issue_Date ) SELECT [Issue ID 1] AS Issue_Key, "steve" AS user, "7777" AS phone, [test information] AS issue, "10/30/2007" AS Issue_Date;
I tried your suggestion:
Expand|Select|Wrap|Line Numbers
  1. $sql='INSERT INTO problems (Issue_key, user, phone, issue, Issue_Date ) SELECT [Issue ID 1] AS Issue_Key, ['.$Fname.'] AS user, ['.$Fphone.'] AS phone, ['.$Fissuetext.'] AS issue, ['.$Fdate.'] AS Issue_Date;';
  2.  
and still got the error:
Expand|Select|Wrap|Line Numbers
  1. Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 5., SQL state 07001 in SQLExecDirect in C:\xampp\htdocs\test.php on line 97 Error in SQL Insert statment please check code
Thank you for your suggestion
Oct 31 '07 #7
code green
1,726 Expert 1GB
You have still got the semi colon within the query statement.
That is not required for any DB
Expand|Select|Wrap|Line Numbers
  1. AS Issue_Date;';
Change to
Expand|Select|Wrap|Line Numbers
  1. AS Issue_Date';
Nov 1 '07 #8
I tried your suggestion:
Expand|Select|Wrap|Line Numbers
  1. $sql='INSERT INTO problems (Issue_key, user, phone, issue, Issue_Date ) SELECT [Issue ID 1] AS Issue_Key, ['.$Fname.'] AS user, ['.$Fphone.'] AS phone, ['.$Fissuetext.'] AS issue, ['.$Fdate.'] AS Issue_Date;';
  2.  
and still got the error:
Expand|Select|Wrap|Line Numbers
  1. Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 5., SQL state 07001 in SQLExecDirect in C:\xampp\htdocs\test.php on line 97 Error in SQL Insert statment please check code
Thank you for your suggestion

So something is going on between the php source and the database. My first suggestion would be to output the query without posting to the database, copy it from the page and then paste it into the database. My guess is that maybe something like single quotes are not being escaped correctly or maybe some are missing. But you want to output the sql exactly as it is being passed to the database like

Expand|Select|Wrap|Line Numbers
  1. $sql='INSERT INTO problems (Issue_key, user, phone, issue, Issue_Date ) SELECT [Issue ID 1] AS Issue_Key, ['.$Fname.'] AS user, ['.$Fphone.'] AS phone, ['.$Fissuetext.'] AS issue, ['.$Fdate.'] AS Issue_Date;';
  2.  
  3. echo $sql;
  4.  
then copy the output and paste that into your database to see if that works. If that doesn't work then try to get it to work and that may narrow down your issue.
Nov 1 '07 #9

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

Similar topics

1
by: annie | last post by:
Hi all, I have recently ported my Access 2000 app to SQL Server, keeping the Access client as the front end using linked tables. I am also using triggers on my SQL tables to trap orphan...
4
by: ron | last post by:
Hi, I have class object that i serialize using the System.Xml.Serialization class. Intermittently the object is not getting serialized correctly, using System.Xml.Serialization classes....
1
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
7
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double...
0
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or...
1
by: Joe | last post by:
Hello All, I am trying to insert a record in the MS Access DB and for some reason I cannot get rid of error message, System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement. ...
3
by: teddysnips | last post by:
I need a trigger (well, I don't *need* one, but it would be optimal!) but I can't get it to work because it references ntext fields. Is there any alternative? I could write it in laborious code...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
2
by: preeti13 | last post by:
Hi guys i am here with my another probelm please help me.trying insert the value into the data base but getting the null value error .I am getting thsi error Cannot insert the value NULL into...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
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,...
0
jinu1996
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...
0
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
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...

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.