Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


MySQL Select works, Update fails

MySQL Select works, Update fails

MySQL Select works, Update fails

I have a bit of a strange one and it's been a while since I've done very much with MySQL.

I'm working on a script that's using the PHP Login Project at it's base. My server is running PHP 5.3.29 and MySQL 5.5.40.

When I run the UPDATE query I get a failure and when I run the SELECT query I get a success. I've tried to simplify the following queries as much as possible.

The UPDATE which fails is this:
$query_update_user = $this->db_connection->prepare('UPDATE users SET user_active = 1 WHERE user_id = 2');

The SELECT which succeeds is this:
$query_update_user = $this->db_connection->prepare('SELECT user_active FROM users WHERE user_id = 2');

Both are executed with this:

Any tips are much appreciated.

RE: MySQL Select works, Update fails

Check the grant tables and check the error returned by mysql whenthequery fails.

RE: MySQL Select works, Update fails

Having select permissions does not mean the user has update permissions.

Try: $query_update_user->erroInfo(); after executing the update query. It should tell you why its failing.

Phil AKA Vacunita
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: MySQL Select works, Update fails

That put me on the right path and now it's working.

Thanks to both of you.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close