ODBC connection to MSAccess

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

Moderators: egami, macek, gesf

Post Reply
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: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Sat Apr 01, 2006 10:45 am

what is the error you are getting?
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

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.

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

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

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: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Sun Apr 02, 2006 10:53 am

Is it working now or what?
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

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: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Sun Apr 02, 2006 1:27 pm

Happends to the best of us ;)
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

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

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 ;)
Sincerely,
Gonçalo "gesf" Fontoura

gesf.org | sessionstart.com | urlms.com

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

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: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Mon Apr 03, 2006 12:08 am

Hehehe, true true. However debugger helps a bit
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests