MySql General Error: 2053

I get an error message:

ERROR: SQLSTATE [HY000]: General error: 2053

I have no idea why this is happening because the code is working fine and the database is being updated, but it still returns this error.

Here is my code:

<?php header("Content-Type: application/json; charset=UTF-8"); require 'UHCauth.php'; try { $conn = new PDO("mysql:host=$mysql_serv;dbname=$mysql_db", $mysql_user, $mysql_pass); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); if(isset($_GET['d6518e47'])) { $USERNAME = $_GET['d6518e47']; $stmt = $conn->prepare( "UPDATE $mysql_table SET KILLS = KILLS+1 WHERE USERNAME = :USERNAME" ); $stmt->execute(array('USERNAME' => $USERNAME)); $row = $stmt->fetch(PDO::FETCH_ASSOC); echo json_encode($row); } else { $stmt = $conn->prepare( "SELECT * FROM $mysql_table ORDER BY McVersion DESC, ModVersion DESC LIMIT 1" ); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); echo json_encode($row); } } catch(PDOException $e) { echo 'ERROR: ' . $e->getMessage(); } ?> 
+8
database php mysql
source share
1 answer

$row = $stmt->fetch(PDO::FETCH_ASSOC); is a string that will cause your error.

Why?

Because nothing happens - in the array - after the update

remember, that

PDO :: FETCH_ASSOC: returns an array indexed by column name as returned in your result set

So, there is no result ... no party

If you want to know the exit status of your command, just use the return value of execute() function

$rv = $stmt->execute(array('USERNAME' => $USERNAME));

+15
source share

All Articles