title: OUT parameter declaration in stored procedure
body: <p>Excuse me for the pretty simple question, but I can't understand what I have to do from similar questions.</p>
  
  <p>I have this code, It works but I got asked to insert input value for CountMacro1, CountMacro2, CountMacro3, CountMacro4, which is always 0. How can I explain to mysql that I want those variables set to 0? set @CountMacro1 = 0; seems not to work, why? Thanks everyone :D</p>
  
  <p>Mysql workbench do a call and a select like this:</p>
  
  <pre><code>set @CountMacro1 = 0;
  set @CountMacro2 = 0;
  set @CountMacro3 = 0;
  set @CountMacro4 = 0;
  call dbcbt.CountMacro_Audit_Scaduti(@CountMacro1, @CountMacro2, @CountMacro3, @CountMacro4);
  select @CountMacro1, @CountMacro2, @CountMacro3, @CountMacro4;
  </code></pre>
  
  <p>Thats the call in php:</p>
  
  <pre><code>$conn = new PDO("mysql:host=$servername;dbname=dbcbt", $username, $password);
  
  
  $sql = 'CALL CountMacro_Audit_Scaduti(@CountMacro1_OUT,@CountMacro2_OUT,@CountMacro3_OUT,@CountMacro4_OUT)';
  $stmt = $conn-&gt;prepare($sql);
  
  $CountMacro1_OUT = 0;
  $CountMacro2_OUT = 0;
  $CountMacro3_OUT = 0;
  $CountMacro4_OUT = 0;
  
  $stmt-&gt;bindParam(1, $CountMacro1_OUT, PDO::PARAM_INT, 10);
  $stmt-&gt;bindParam(2, $CountMacro2_OUT, PDO::PARAM_INT, 10);
  $stmt-&gt;bindParam(3, $CountMacro3_OUT, PDO::PARAM_INT, 10);
  $stmt-&gt;bindParam(4, $CountMacro4_OUT, PDO::PARAM_INT, 10);
  
  print "Values of bound parameters _before_ CALL:\n";
  print "  1: {$CountMacro1_OUT} 2: {$CountMacro2_OUT} 3: {$CountMacro3_OUT} 4: {$CountMacro4_OUT}\n";
  
  $stmt-&gt;execute();
  
  print "Values of bound parameters _after_ CALL:\n";
  print "  1: {$CountMacro1_OUT} 2: {$CountMacro2_OUT} 3: {$CountMacro3_OUT} 4: {$CountMacro4_OUT}\n";
  </code></pre>
  
  <pre><code>CREATE DEFINER=`root`@`localhost` PROCEDURE `CountMacro_Audit_Scaduti`(
  OUT CountMacro1 int,
  OUT CountMacro2 int,
  OUT CountMacro3 int,
  OUT CountMacro4 int
  )
  BEGIN
  set @CountMacro1 = 0;
  set @CountMacro2 = 0;
  set @CountMacro3 = 0;
  set @CountMacro4 = 0;
  
  select count(*)
  INTO CountMacro1
  from t_audit
  WHERE (t_audit.Data_Scadenza &lt; NOW()) AND (t_audit.Data_Completamento ="" OR t_audit.Data_Completamento is null) AND (t_audit.Macro1= 1 OR t_audit.Macro2= 1 OR t_audit.Macro3= 1);
  
  select count(*)
  INTO CountMacro2
  from t_audit
  WHERE t_audit.Data_Scadenza &lt; NOW() AND (t_audit.Data_Completamento ="" OR t_audit.Data_Completamento is null) AND (t_audit.Macro1= 2 OR t_audit.Macro2= 2 OR t_audit.Macro3= 2);
  
  select count(*)
  INTO CountMacro3
  from t_audit
  WHERE t_audit.Data_Scadenza &lt; NOW() AND (t_audit.Data_Completamento ="" OR t_audit.Data_Completamento is null) AND (t_audit.Macro1= 3 OR t_audit.Macro2= 3 OR t_audit.Macro3= 3);
  
  select count(*)
  INTO CountMacro4
  from t_audit
  WHERE t_audit.Data_Scadenza &lt; NOW() AND (t_audit.Data_Completamento ="" OR t_audit.Data_Completamento is null) AND (t_audit.Macro1= 4 OR t_audit.Macro2= 4 OR t_audit.Macro3= 4);
  
  END 
  </code></pre>