title: Script for cron job not working. PHP/MySQL
body: <p>I set up a cron job to run the following script every 30 min, Basically this script selects article info from <strong>stories</strong> table where field <strong>showing=0</strong> And it than counts votes related to that article, the votes are located in <strong>votes</strong> table. <strong>itemname_field</strong> in votes table is equal to <strong>id</strong> field in stories table.
  If you need more information on database structure and voting system, I describe it in depth here: <br />
  <a href="https://stackoverflow.com/questions/8609678/set-a-cron-job-to-update-article-information-depending-on-its-vote-values">Set a cron job to update article information depending on its vote values</a></p>
  
  <pre><code>&lt;?php 
      mysql_connect("localhost","username","password") or die (mysql_error("There was an error in connection"));
      mysql_select_db("database") or die (mysql_error("There was an error in connection"));
  
      $query = "select sum(vt.vote_value) as vote_value, vt.item_name from Votes vt join stories st on st.id = vt.item_name and st.showing = 0 group by vt.item_name";
      $result = mysql_query($query); 
      while($row = mysql_fetch_array($result))
      {
          if($row['vote_value'] &gt; 9) {
              $showing = 1;
          }
          else if($row['vote_value'] &lt; -9) {
              $showing = 2;
          }
          else {
              $showing = 0;
          }
          $query2 = "UPDATE `stories` SET `showing` = $showing WHERE `id` = '".$row['item_name']."'";
          mysql_query($query2); 
      }
  ?&gt;
  </code></pre>
  
  <hr>
  
  <p>Can anyone suggest the reason, why this script is not working? If everything is alright with script, could it be something in cron job that needs to be done?</p>
  
  <p><strong>EDIT:</strong> when I run script in browser it gives the following error:</p>
  
  <pre><code>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
  </code></pre>
  
  <p>Which is this line <code>while($row = mysql_fetch_array($result))</code></p>