mysql - PHP script which utilizes an SQL query returning false even though DB is updated -
i'm having trouble simple php script that's part of user registration system.
upon entering user information in registration form, invoke following php:
if ($db->isuserexisted($email)) { // user existed - error response $response["error"] = true; $response["error_msg"] = "user existed"; echo json_encode($response); } else { // store user $user = $db->storeuser($name, $email, $password); if ($user != false) { // user stored $response["error"] = false; $response["userid"] = $user["unique_id"]; $response["user"]["name"] = $user["name"]; $response["user"]["email"] = $user["email"]; $response["user"]["created_at"] = $user["created_at"]; $response["user"]["updated_at"] = $user["updated_at"]; echo json_encode($response); } else { // user failed store $response["error"] = true; $response["error_msg"] = "error occured in registration"; echo json_encode($response); } }
now, here storeuser function i'm accessing through object reference db_functions class:
public function storeuser($name, $email, $password) { $uuid = uniqid('', true); $hash = $this->hashssha($password); $encrypted_password = $hash["encrypted"]; // encrypted password $salt = $hash["salt"]; // salt $grade = "novice"; $eloscore = 1200; $result = mysql_query("insert chessmates.user_accounts (unique_id, name, email, grade, encrypted_password, eloscore, salt, created_at) values('$uuid', '$name', '$email', '$grade', '$encrypted_password', $eloscore, '$salt', now())"); // check successful store if ($result != false) { // user details $uid = mysql_insert_id(); // last inserted id $result = mysql_query("select * users uid = $uid"); // return user details return mysql_fetch_array($result); } else { return false; } }
you'll notice if storeuser function returns false - occurs in case of mysql_query returning false - returned android application array containing error_msg "error occured in registration".
this message seeing when initiate whole registration cascade clicking 'register' button on app.
however, database being updated correctly!
i think i've narrowed issue down mysql_query returning false, how possible if query successful?
perhaps select query problem.
you inserting chessmates.user_accounts
, yet selecting users
.
$result = mysql_query("select * users uid = $uid");
Comments
Post a Comment