Windows 任务调度程序中的 PHP 脚本

编程入门 行业动态 更新时间:2024-10-28 09:23:40
本文介绍了Windows 任务调度程序中的 PHP 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我编写了 php 脚本,它在浏览器中作为网页成功执行.但是当我使用 windows task scheduler 调度脚本时,脚本将成功运行(windows task scheduler 中没有错误)但在数据库中没有任何结果;它应该更新一些行.

I wrote php script which executed successfully as a web page in the browser. But when I schedule the script using windows task scheduler, the script will run successfully (with no error in windows task scheduler) but result nothing in the database; it should update some rows.

脚本如下:

<?php $con = mysqli_connect("xxx", "xxx", "xxx"); mysqli_select_db($con, "xxx"); $tns = " (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = xxx)) ) (CONNECT_DATA = (SERVICE_NAME = xxx.xxx.xxx.xx) ) ) "; if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); }; $conn = oci_connect("xxx", "xxx", $tns); if (!$conn) { $m = oci_error(); echo $m['message'], "\n"; exit; } else { $Orcle_Sql = "select ID,E_OFFICIAL_NAME,Password from xxx"; $array = oci_parse($conn, $Orcle_Sql); oci_execute($array); while ($row = oci_fetch_array($array)) { $ID = $row[0]; $Password = $row[2]; $sql = "UPDATE students_info set password='$Password' WHERE ID= '$ID'"; $Update_query = mysqli_query($con, $sql); } } mysqli_close($con); oci_close($conn); ?>

为什么在浏览器中运行脚本的行为与在 Windows 任务调度程序中运行的行为不同?

Why does running the script behave different in browser than in windows task scheduler?

推荐答案

我通过批处理文件运行我的 PHP 脚本来解决它.

I solve it by running my PHP script through batch file.

并在 Windows 任务调度程序中调度批处理文件.

and scheduling the batch file in Windows task scheduler.

这篇文章对我帮助很大:

this post helped me so much:

www.devside/wamp-server/running-php-scripts-as-cron-jobs-on-windows

更多推荐

Windows 任务调度程序中的 PHP 脚本

本文发布于:2023-11-23 19:23:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622600.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   程序   Windows   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!