Jump to content

error in executing query


jimfog

Recommended Posts

below is a function that updates a user's phone:

function update_phone($connection,$phone,$sessioneml){     $connection->set_charset("utf8");     if($stmt = $connection->prepare(             'UPDATE business_users                SET phone=(?)              WHERE (SELECT users.user_ID                     FROM users                     WHERE users.user_ID=business_users.crID                     and users.email=(?))'             ))              {     $stmt->bind_param('ss',$phone,$sessioneml);     $stmt->execute();     if($stmt->errno!==0)         {            error_log("error message for ajax_update-phone()-execution failed:".$stmt->error."for buser:".$sessioneml.",time of error:".date('d F Y h i')." n", 3,"error_log.log");            mail_error($sessioneml,'941');return false;           }              }     else     {         error_log("error message for ajax_update-phone()-prepare failed:".$connection->error."for buser:".$sessioneml.",time of error:".date('d F Y h i')." n", 3,"error_log.log");         mail_error($sessioneml,'948');return false;        }        return true;     }

it seems though that the connection to the dbase never takes place...

I get error executing query at $connection->set_charset("utf8")....even if I remove this line...the update query beneath never takes place...

var_dump $connection gives this:

object(mysqli)#1 (19) {  ["affected_rows"]=>  int(-1)  ["client_info"]=>  string(79) "mysqlnd 5.0.11-dev - 20120503 - $Id: 1514feb3700aa52d513182fcdc87f2c66f06d152 $"  ["client_version"]=>  int(50011)  ["connect_errno"]=>  int(0)  ["connect_error"]=>  NULL  ["errno"]=>  int(0)  ["error"]=>  string(0) ""  ["error_list"]=>  array(0) {  }  ["field_count"]=>  int(2)  ["host_info"]=>  string(20) "localhost via TCP/IP"  ["info"]=>  NULL  ["insert_id"]=>  int(0)  ["server_info"]=>  string(6) "5.6.15"  ["server_version"]=>  int(50615)  ["stat"]=>  NULL  ["sqlstate"]=>  string(5) "HY000"  ["protocol_version"]=>  int(10)  ["thread_id"]=>  int(149)  ["warning_count"]=>  int(0)}

I do not see any error above....

 

Lastly the function you see above is contained in another function....I do not want to include it yet...so as to avoid complexity.

 

I just want you to tell me what can you make out of the var_dump output?

Link to comment
Share on other sites

You could check for errors with the other mysqli functions, but one issue may be that you have a query pending on that connection from the other function while you're trying to do that. If you've prepared a query but haven't executed it yet, or if you've executed a select query but haven't gotten the results, and you try to run another query on the same connection then that might be a problem.

Link to comment
Share on other sites

You could check for errors with the other mysqli functions, but one issue may be that you have a query pending on that connection from the other function while you're trying to do that. If you've prepared a query but haven't executed it yet, or if you've executed a select query but haven't gotten the results, and you try to run another query on the same connection then that might be a problem.

you were absolutely correct...there was a query pending...I just used stmt->close to close the connection there...once done there was no problem any more.

It is the first time I encountered such an issue.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...