Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003

    Arrow Unanswered: ms access ADODB connection, sql update error

    I am connecting to a microsoft access 2000 database using the following PHP code:

    $dbconn = new COM("ADODB.Connection") or die("Cannot start ADODB Connection from 'database_conn.php'");
    $dbconn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" . realpath("database/ubmc_db.mdb"));

    fairly bog standard. I am able to retieve rows using the $dbconn->Execute function.

    I get problems when I try and run update statements:

    $sqlquery = "UPDATE Members SET password = 'newpassword' WHERE members.mid = 1";

    $cUpd = $dbconn->Execute($sqlquery);

    Again this is bog standard php and sql code, but I get the following error:

    Warning: (null)(): Invoke() failed: Exception occurred. Source: Microsoft JET Database Engine Description: Syntax error in UPDATE statement.

    For the life of me, I can't see why it isn't working HELP, plz.

    I am running PHP 4.3.0 on a WinXP.


  2. #2
    Join Date
    Sep 2003
    Wisconsin, USA


    I never use adodb or com (or Jet) in my php precisely because it can be very confusing when things break.

    What I would do is set up a system DSN for that access database and access in it php via the odbc drivers. I know, it's a lot of work to re-write ... maybe not the best solution, but it's my advice.

    Alternatively, run that sql from access. (set up a new query, and then go to sql-view, and you can type direct sql like this.) It's been quite a while since I used Jet directly, so there may be some funky things you have to do like use double-quotes or []'s around the table names. Running the code in Access will give you an idea if there's something it dislikes (although Access SQL !== Jet SQL).

    I always use odbc for this stuff, because it makes the code MUCH more portable. If you ever decide to switch to mssql or postgres or mysql (or even change the underlying OS to linux, for example), you simply have to change the odbc connection string and all your code instantly works on said DB / OS.

    Sorry it's not the answer you were looking for, but depending on the size of your project, it may be worth it to you. (And definitely something to think about in the future. MS Access as a multi-user, web-enabled database server is never a good long-term plan.)

  3. #3
    Join Date
    Oct 2003
    Turned out this problem occurred because the IUSR acconut that PHP works under didn't have NT write permissions set to it.

    I much prefer working with mysql, but in this case the hosting that the site is being run on isn't offerring it.

    THanks for the suggestion, I will bare in mind in the future.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts