title: PHP array_sum not working
body: <p>I am trying to query an SQL table, and then have all the values from one column (it's a "tinyint(1)") added up and then printed, using array_sum. (Currently there are only two rows). </p>
  
  <p>When both rows have a "1" in that column, it gives 2, the correct answer. And when they are both "0" it gives  0, correct again. But when one is "1" and one "0" it gives 2, not 1.</p>
  
  <p>This is my code
  <code>
      
  
  <pre><code>$con = mysql_connect("XXX","XXX","XXX");
  
  if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
  
  mysql_select_db("XXX_test", $con);
  
  $day = $_GET["day"];
  
  $query = mysql_query("SELECT $day FROM sites");
  
  if (!$query)
    {
    die('Could not query: ' . mysql_error());
    }
  
  $rows = mysql_fetch_array($query);
  
  echo array_sum($rows);
  
  mysql_close($con);
  </code></pre>
  
  <p>?>
  </code></p>
  
  <p>Thanks for any help.</p>
  
  <p><strong>--UPDATE--</strong><br>
  I just solved this myself.</p>
  
  <p>With this, if you want to know:
      $query = mysql_query("SELECT name, SUM($day) AS Alerts FROM sites");</p>
  
  <pre><code>while($row = mysql_fetch_array($query))
    {
    echo $row['Alerts'];
    echo "&lt;br /&gt;";
    }
  </code></pre>