Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL Select works, Update fails 2

Status
Not open for further replies.

mridler2

Programmer
Jan 27, 2015
2
0
0
CA
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:
$query_update_user->execute();

Any tips are much appreciated.
Thanks
 
Check the grant tables and check the error returned by mysql whenthequery 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
 
That put me on the right path and now it's working.

Thanks to both of you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top