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

Asked

Viewed 911 times

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();
}

How should be the correct parameter for the float type ?

1 answer

3


Looks like you forgot to set the value for :user
You are setting only the value to :creditosplayer in:

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

Do:

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.