title: How to fix incorrect syntax near '@P1'
body: <p>My login procedure in SQL Server generates an error.</p>
  <p>Here is my code:</p>
  <pre><code>session_start();
  $_SESSION[&quot;utilizador&quot;] = $_POST['utilizador'] ?? null;
  $_SESSION[&quot;password&quot;] = $_POST['password'] ?? null;
  // login action
      if (isset($_SESSION[&quot;utilizador&quot;]) &amp;&amp; isset($_SESSION[&quot;password&quot;])){    
          $utilizador = $_SESSION['utilizador']; // set variable
          $password = $_SESSION['password']; // set variable
          
          require 'ligacao_bd.php'; // connect database
          $pdo = Conexao::getConnection();
          $sql = &quot;EXEC sp_login(?, ?)&quot;; 
          $statement = $pdo-&gt;prepare($sql);
          $statement-&gt;bindParam(1, $utilizador, PDO::PARAM_STR);
          $statement-&gt;bindParam(2, $password, PDO::PARAM_STR);
          $statement-&gt;execute();
          $resultado = $statement-&gt;fetch(PDO::FETCH_ASSOC);
  
  
          if ($resultado) { // if there is a result go to 
              header(&quot;location: utilizadores.php&quot; );
          }else{
              echo &quot;NO PERMISSIONS&quot;;
          }
      }
      
  </code></pre>
  <p>When I execute it generates the error:</p>
  <blockquote>
  <p>Uncaught PDOException: SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near '@P1'.&quot; supposedly in line &quot;<em>$statement-&gt;execute();</em></p>
  </blockquote>