title: Retrieving Data of Stored Procedure Using ODBC and PHP
body: <p>I'm trying to retrieve values of out parameter by using ODBC and PHP. I've been searching online but to no avail. There are a lot of resolves for PDO and mysqli and I only found <a href="http://www.easysoft.com/support/kb/kb01037.html">this</a> for odbc. I'm kind of lost by the parameter and the operation involve. </p>
  
  <p>I'm able to make the connection to the database but the error always pops up. I couldn't figure them out.</p>
  
  <blockquote>
    <p>[Sybase][ODBC Driver] Invalid string or buffer length</p>
  </blockquote>
  
  <p>Any suggestion?</p>
  
  <pre><code>&lt;?php
  
  $conn=odbc_connect("dsn", " ", " ");
  
  if (!$conn)
  {
  exit("Connection Failed: " . $conn);
  }
  
  $sql=odbc_prepare("CALL ndTblUser (@varUserId,@varUserPwd)"); 
  $stmt=odbc_execute($sql, "SELECT @varUserId as UserId, @varUserPwd as UserPwd");
  
  $rs=odbc_exec($conn,$stmt);
  
  if (!$rs)
  {
  exit("Error : " . odbc_errormsg());
  }
  echo "&lt;table&gt;&lt;tr&gt;";
  echo "&lt;th&gt;Id&lt;/th&gt;";
  echo "&lt;th&gt;Password&lt;/th&gt;&lt;/tr&gt;";
  
  while (odbc_fetch_row($rs))
  {
  $UserId=odbc_result_all($rs,"UserId");
  $UserPwd=odbc_result_all($rs,"UserPwd");
  echo "&lt;tr&gt;&lt;td&gt;$UserId&lt;/td&gt;";
  echo "&lt;td&gt;$UserPwd&lt;/td&gt;&lt;/tr&gt;";
  }
  
  odbc_close($conn);
  ?&gt;
  </code></pre>