Jump to content

ahmeddhanani

New Members
  • Posts

    4
  • Joined

  • Last visited

ahmeddhanani's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks, I will check that out on the internet. Thanks for guiding me!
  2. Thank you for your response. Actually I wanted my script to run every our from the time of posting a new post. Your approach seems to be a clean and nice approach. But just one thing. doesn't ignore_user_abort(true) tells the browser to work on the back end? Or is there any other way to run a script on the back end, on the server and redirects the user to some other page on the website?
  3. Thank you for your response. Actually I wanted my script to run every our from the time of posting a new post. Your approach seems to be a clean and nice approach. But just one thing. doesn't ignore_user_abort(true) tells the browser to work on the back end? Or is there any other way to run a script on the back end, on the server and redirects the user to some other page on the website?
  4. I have a php script that takes the input and inserts it into the mysql database. As soon as the entry in the table is completed, this script calls another script using shell_exec(). Here is the first php script: if(isset($_POST['post_arg'])){ $theme = $_POST['topic_theme']; $des = $_POST['detail']; $hrs_to_go = 36; $t = time(); $conn = mysql_connect('localhost', 'root', '') or die(mysql_error()); mysql_select_db('topics'); $sql_query = "INSERT INTO `topics`.`theme`(heading, description, hrs_to_go, status, time) VALUES ('$theme', '$des', '$hrs_to_go', 'yes', '$t')"; $ret_val = mysql_query($sql_query, $conn) or die(mysql_error()); $row = mysql_fetch_assoc(mysql_query("SELECT id FROM `theme` where heading = '$theme'")); $themeID = $row['id']; shell_exec("php timer_script.php $themeID"); } I want my second script to fetch the time and hrs_to_go from my table and update the field hrs_to_go accordingly. But unfortunately the second script does not work properly and the browser keeps on loading without any redirect. Here is the second script: ignore_user_abort(true); session_start(); set_time_limit(0); $conn = mysql_connect('localhost', 'root', ''); mysql_select_db('topics'); $themeID = $_SERVER['argv'][1]; $fetched_row = mysql_fetch_assoc(mysql_query("SELECT time, hrs_to_go FROM `theme` WHERE id = '$themeID'")); while(1){ $htm = time() - (int)$fetched_row['time']; $htm = round($htm / 3600); $h = (int)$fetched_row['hrs_to_go'] - $htm; if($h == 0){ mysql_query("UPDATE `theme` SET status = 'no' WHERE id = '$themeID'") or die(mysql_error()); break; } else { mysql_query("UPDATE `theme` SET hrs_to_go = '$new' WHERE id = '$themeID'") or die(mysql_error()); } sleep(10); } Although my variables are hrs_togo but I've kept the iterval time smaller to see the changes.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.