Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6964271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:54:14+00:00 2026-05-27T15:54:14+00:00

I set up a cron job to run the following script every 30 min,

  • 0

I set up a cron job to run the following script every 30 min, Basically this script selects article info from stories table where field showing=0 And it than counts votes related to that article, the votes are located in votes table. itemname_field in votes table is equal to id field in stories table.
If you need more information on database structure and voting system, I describe it in depth here:
Set a cron job to update article information depending on its vote values

<?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'] > 9) {
            $showing = 1;
        }
        else if($row['vote_value'] < -9) {
            $showing = 2;
        }
        else {
            $showing = 0;
        }
        $query2 = "UPDATE `stories` SET `showing` = $showing WHERE `id` = '".$row['item_name']."'";
        mysql_query($query2); 
    }
?>

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?

EDIT: when I run script in browser it gives the following error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL

Which is this line while($row = mysql_fetch_array($result))

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:54:15+00:00Added an answer on May 27, 2026 at 3:54 pm

    The error message you quote means you have an error in your query. Run it though a mysql client to get more info, or echo mysql_error() in php.

    In such cases mysql_query() returns boolean false, you can use this for error handling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a cron job set up to run testemail.php. This works fine, every
I am trying to set up a cron job to, every 15 min, run
I have set up a cron job in plesk to run a cleanup script
I need to add a cron job thru a script I run to set
I have a php script run as a cron job that executes a set
I have a CRON job php script that I just set up not too
I am setting up a cron job to run a single PHP script which
I want to set up a cron job which will execute a command every
So, I set up a cronjob to run the following command: php /var/www/path/to/cron/do-stuff.php The
How do I set up a cron job (cron2.php) to run after and only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.