This is my code and my error, what is wrong?

$connection = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=mydb.mdb", "", "") or die ("Sorry I could not open the database.");
$query = "UPDATE StaffRewards SET ItemName = '$ItemName' WHERE ID = $ID";
odbc_exec($connection, $query) Or Die ("Error: " . odbc_error());
odbc_close($connection);
header('Location: index.php'); 	
Error: S1000

    Perhaps there is a no DNS issue, how else can I connect to a database and update rows, getting results isn't a issue

      Here is my php info on ODBC

      odbc
      ODBC Support enabled
      Active Persistent Links 0

      Active Links 0

      ODBC library Win32

      Directive Local Value Master Value
      odbc.allow_persistent On On
      odbc.check_persistent On On
      odbc.default_cursortype Static cursor Static cursor
      odbc.default_db no value no value
      odbc.default_pw no value no value
      odbc.default_user no value no value
      odbc.defaultbinmode return as is return as is
      odbc.defaultlrl return up to 4096 bytes return up to 4096 bytes
      odbc.max_links Unlimited Unlimited
      odbc.max_persistent Unlimited Unlimited

        Step 1: google "odbc error s1000". Which in this case isn't very helpful.

        Step 2: Read php doc and make your code check the results of its function calls
        http://se.php.net/manual/en/function.odbc-connect.php which tells you to

        if ($connection) {
        
        }
        else {
        	# connction error
        }

        And where it says #connection error, make use of error and error message.

        http://se.php.net/manual/en/function.odbc-exec.php tells you to

        $result = odbc_exec(...);
        if ($result) {
        
        }
        else {
        	# error
        }
        

        If you do not need the result, and really wish to die on exec error, your way works. But including the error message (see above) is a really really good idea. Especially for an error which according to the ODBC error list found from googling states that S1000 can be returned from

        All ODBC functions except:SQLAllocEnv
        SQLError

        http://se.php.net/manual/en/function.odbc-close.php tells you that this is bad

        odbc_close(false);
        

        Which you know, from documentation on odbc_connect (first link), is returned on connect error. So only call close if connect was successful.

          Thank you so much for your reply. I've tried and test all of the above and still get the same error, S100

          Would it be some kind of read/write issue with the database?

            I'm gonna start by quoting myself here...

            johanafm;10963689 wrote:

            And where it says #connection error, make use of error and error message.

            And no, S1000 is what odbc_error tells you. I'm talking about the error message, not the error number. In other words, odbc_errormsg. Did you try anything of what I wrote? Did you read the documentation I linked to? And in particular, did you read the page about ordb_errormsg?

              Umm yes it did. Never mind though I've solved the issue.

                Write a Reply...