PDO SQLSTATE [07002]: COUNT field incorrect or syntax error [duplicate]

0

I'm having trouble making a decrease in sql with pdo. I'm getting the following error

  SQLSTATE [07002]: [Microsoft] [ODBC Driver 11 for SQL Server] COUNT field incorrect or syntax error

code

<?php
ob_start();
include'../../classes/config.php';
session_start();
$username = $_SESSION['ID'];

$creditosplayer = (float)$_POST["creditos"];


try {
  $pdo = new PDO($pdoconnection, $user, $pass);
  $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

  $query = $pdo->prepare("UPDATE [omegashop].[dbo].[cad_users] SET                         [creditos] = :creditosplayer WHERE [userid] = :user");
  $query->bindValue(':creditosplayer', $creditosplayer);
  $query->execute();

  echo 1;
} catch(PDOException $e) {
  echo 'Error: ' . $e->getMessage();
}

What should be the correct parameter for float type?

    
asked by anonymous 30.10.2016 / 21:58

1 answer

3

It seems like you forgot to set the value to :user
Setting only the value for :creditosplayer in:

  

$query->bindValue(':creditosplayer', $creditosplayer);

Make:

  

$query->bindValue(':creditosplayer', $creditosplayer);

     

$query->bindValue(':user', $username);

    
30.10.2016 / 22:53