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: - 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
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?
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.
- SQL error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 5.,
This is usually because you are using a wrong field name
- 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
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? - 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;
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? - 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: - $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;';
-
and still got the error: - 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
You have still got the semi colon within the query statement.
That is not required for any DB
Change to
I tried your suggestion: - $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;';
-
and still got the error: - 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 - $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;';
-
-
echo $sql;
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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....
|
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;
|
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...
|
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...
|
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.
...
|
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...
|
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...
|
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...
|
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: 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...
|
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...
|
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: 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: 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...
| |