title: PHP Call mysql stored procedure with in parameter
body: <p>I'm calling a mysql stored procedure with two input parameters. This is the code I have:</p>
  
  <pre><code>if (isset($_POST['button1'])) {
      $con = mysql_connect("localhost:3306","root","");
      if (!$con) {     
          echo '&lt;b&gt;Could not connect.&lt;/b&gt;';
          die(mysql_error()); // TODO: better error handling
      } else {          
          mysql_select_db("php_database_1", $con);
  
          $username_v = $_POST['username'];
          $password_v = $_POST['password'];
  
          $stmt = $dbh-&gt;prepare("CALL login(?, ?)");
          $stmt-&gt;bindParam(2, $username_v, $password_v, PDO::PARAM_STR|PDO::PARAM_INPUT_OUTPUT, 4000); 
  
          // call the stored procedure
          $stmt-&gt;execute();
  
          print "procedure returned $username_v\n";
  </code></pre>
  
  <p>When executing, I get:</p>
  
  <blockquote>
    <p>Notice: Undefined variable: dbh in E:\xampp\htdocs\php4\default.php on line 52
    Fatal error: Call to a member function prepare() on a non-object in E:\xampp\htdocs\php4\default.php on line 52</p>
  </blockquote>
  
  <p>How can I fix this?</p>
  
  <p>Thanks.</p>