Jump to content

PHP -> MSACCESS Update query fails


Cep

Recommended Posts

Hello,

I have had little luck in finding a decent reference to the SQL syntax needed for each query when using PHP to MS ACCESS.

I have written an update query which I used in one system but for the love of god can't get it to work in a new system I am constructing and it makes absolutely no sense whatsoever.

Here is the code,

[code]
function changepassword($user, $oldpass, $newpass) {

      $sql = "SELECT * FROM budgetsys_users WHERE Username = '{$user}' AND Password = '{$oldpass}'";

      $result = odbc_exec(db(),$sql) or die ("SQL Error: Function changepassword - Select users");

      $rowcount = odbc_record_count($result, db(), $sql);

      if ($rowcount==0) {

        $changed = "Invalid Cookie";

      } else {

        $myrow = odbc_fetch_array(odbc_exec(db(),$sql)) or die("SQL Error: Function changepassword - Get user");

        $usr_id = $myrow["UserID"];
        $usr_pass = $myrow["Password"];

        if ($usr_pass==$oldpass) {

            $sql_upd = "UPDATE budgetsys_users SET budgetsys_users.Password = '{$newpass}' WHERE budgetsys_users.UserID = {$usr_id}";
            $upd_result = odbc_exec(db_src(),$sql_upd) or die ("SQL Error: Function changepassword - unable to update user");
            $changed = "Password changed";

        } else {

            $changed = "Incorrect Cookie data";

        }
      }
return $changed;
}
[/code]

The code can run the select query, no problem. However it will not run an update. The database has read/write permissions for all users including IUSR (internet guest account).

Knowing from past experience that Access can be funny about the way in which a query is written I started to examine the possibility its something written wrong or missing, but as I have said I have used this query before with no problems yet no matter what tests I try for example putting data directly into the query (instead of using variables) it will not run.

Any ideas?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.