ODBC connection to MSAccess

Do you have questions regarding other database enginges (not MySQL) -- ask here!

Moderators: macek, egami, gesf

MrMoz
New php-forum User
New php-forum User
Posts: 5
Joined: Fri Mar 24, 2006 3:06 am

ODBC connection to MSAccess

Postby MrMoz » Fri Mar 24, 2006 3:10 am

Hi I'm connecting to an Access 2003 DB with PHP 4 and attmepting to update a table but I get syntax error everytime can anyone explain? my code is below.

Thanks in advance.

// Microsoft Access connection string
$conn=new COM("ADODB.Connection") or die("Cannot start ADO");
$conn-> open("Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Jet OLEDB:Database Password=***;Data Source=****;");

$conn -> execute("UPDATE Perfumes SET Perfdesc=$perfd WHERE ID=$number LIMIT 1");

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Sat Apr 01, 2006 10:45 am

what is the error you are getting?

MrMoz
New php-forum User
New php-forum User
Posts: 5
Joined: Fri Mar 24, 2006 3:06 am

Not sure

Postby MrMoz » Sun Apr 02, 2006 12:31 am

I'm not sure as I'm not connected to that network from home but I think it was a syntax error that had something todo with Jet4. I fixed the problem by replacing the update query with a delete and insert but am still interested as to why it didn't work.

Thanks.

User avatar
Coditor
New php-forum User
New php-forum User
Posts: 243
Joined: Wed Feb 01, 2006 9:18 am
Location: Netherlands
Contact:

Postby Coditor » Sun Apr 02, 2006 6:35 am

Could it be that Perfdesc is a textfield? In that case you need to enclose $perf with single quotes ( ' ).

If you can post your insert query, we might be able to explain why the update fails.

Coditor

MrMoz
New php-forum User
New php-forum User
Posts: 5
Joined: Fri Mar 24, 2006 3:06 am

Postby MrMoz » Sun Apr 02, 2006 6:39 am

Yeah I tried with quotes round Perfdesc but I've just noticed that I've probablt done something very stupud and changed the field name and not the query. Which wouldn't help!

Thanks guys.

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Sun Apr 02, 2006 10:53 am

Is it working now or what?

MrMoz
New php-forum User
New php-forum User
Posts: 5
Joined: Fri Mar 24, 2006 3:06 am

Postby MrMoz » Sun Apr 02, 2006 12:26 pm

Yes thanks I can't believe how doumb that was!

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Sun Apr 02, 2006 1:27 pm

Happends to the best of us ;)

User avatar
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Sun Apr 02, 2006 3:10 pm

The funny is that sometimes we're so sure about what we've done and even looking to the code we can't see we miss a quote or comma :) That happens ;)

User avatar
Coditor
New php-forum User
New php-forum User
Posts: 243
Joined: Wed Feb 01, 2006 9:18 am
Location: Netherlands
Contact:

Postby Coditor » Sun Apr 02, 2006 11:56 pm

Sounds familiar :) That's why it's always good to have someone else look at your code. A fresh view does miracles.

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Postby Alexej Kubarev » Mon Apr 03, 2006 12:08 am

Hehehe, true true. However debugger helps a bit


Return to “Other Database Engines”

Who is online

Users browsing this forum: No registered users and 0 guests

cron