By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,968 Members | 1,843 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,968 IT Pros & Developers. It's quick & easy.

php sql insert error - stumped!

P: n/a
MP
ok - I have no idea what's doing on. In a nutshell I am doing a SQL
insert in a Access database from PHP but am getting an error.

Here is the code:

// PHP db connection
$db = 'C:\\Phpweb\\govDB.mdb';
$conn = new COM('ADODB.Connection');
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db");

and here is the error:

Warning: (null)(): Invoke() failed: Exception occurred. Source:
Microsoft JET Database Engine Description: Syntax error in INSERT INTO
statement. in c:\phpweb\detailcard.php on line 198

and here is a print out of the sql:
INSERT INTO Cards(active,companynam,division,streetnumb,street ,town_city,province,filetitle,air,water,sewage,ptt w,partVIII,part46,miscellany,grr,grrfile)
VALUES ('0','1 HOUR PHOTO PLUS','ob','24','RAMBLER
DRIVE','BRAMPTON','Ontario','SI HP BR RA','0','0','0','0','0','0','REG
347 - 1592500','1592500','700')

the sql works if I do a query in Access.....

please help me out...I'm losing my mind!

Thanks!
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 12 Nov 2003 19:19:29 -0800, mp******@uoguelph.ca (MP) wrote:
and here is a print out of the sql:
INSERT INTO Cards(active,companynam,division,streetnumb,street ,town_city,province,filetitle,air,water,sewage,ptt w,partVIII,part46,miscellany,grr,grrfile)
VALUES ('0','1 HOUR PHOTO PLUS','ob','24','RAMBLER
DRIVE','BRAMPTON','Ontario','SI HP BR RA','0','0','0','0','0','0','REG
347 - 1592500','1592500','700')


Access is notoriously lenient. I don't want to cause havoc, but your
field names should really all be prepended with an indicator to the
data type (e.g. nField for numeric, cField for char/varchar). It's
just a good practice to get into.

It looks like you are setting all field values to string/character
data... are none of the fields numeric at all? Access will probably
let you get away with setting a number to a string value, but I'm
betting PHP won't.
Jul 17 '05 #2

P: n/a
MP
ok thanks I'll check that out...as per the names is a government
database so I can't change it...I gotta work with what I'm given :)

Thanks
Kafooey <ka*****@yahoo.co.uk> wrote in message news:<fb********************************@4ax.com>. ..
On 12 Nov 2003 19:19:29 -0800, mp******@uoguelph.ca (MP) wrote:
and here is a print out of the sql:
INSERT INTO Cards(active,companynam,division,streetnumb,street ,town_city,province,filetitle,air,water,sewage,ptt w,partVIII,part46,miscellany,grr,grrfile)
VALUES ('0','1 HOUR PHOTO PLUS','ob','24','RAMBLER
DRIVE','BRAMPTON','Ontario','SI HP BR RA','0','0','0','0','0','0','REG
347 - 1592500','1592500','700')


Access is notoriously lenient. I don't want to cause havoc, but your
field names should really all be prepended with an indicator to the
data type (e.g. nField for numeric, cField for char/varchar). It's
just a good practice to get into.

It looks like you are setting all field values to string/character
data... are none of the fields numeric at all? Access will probably
let you get away with setting a number to a string value, but I'm
betting PHP won't.

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.