我在cpanel中添加了cronjob以在php中使用textloal发送短信。它在cronjob之外非常有效。在cronjob中运行它后,它不会发送任何短信。
这是我的代码
<?php
include('dbc.php');
error_reporting(E_ALL); ini_set('display_errors', 1);
require('php-in/textlocal.class.php');
//require('php-in\Textlocal.class.php');
//require('consultantnext.com/danceschool/php-in/Textlocal.class.php');
$sql="SELECT *
FROM admin t1, batchinfo t2
WHERE t1.batchname= t2.batchname
AND t1.branchname= t2.branchname";
$result= mysqli_query($conn,$sql)
or die($sql."<br/><br/>".mysql_error());
if (mysqli_num_rows($result)>0) {
while($row=mysqli_fetch_array($result)) {
//echo $row['mobile'];
$mobile=$row['mobile'];
$time=$row['time'];
//echo $time;
$numbers=(explode(" ",$mobile));
foreach ($numbers as $item) {
echo $item;
}
$Textlocal = new Textlocal(false, false, 'e34FsEpkeUo-
uLJ17oDYeEgHBucRHTnNtHhrE39Pj4');
//$numbers = array(919384191234,918056377914);
$sender = 'TXTLCL';
$message = "Dear student your class schedule for tomorrow '$time'";
$response = $Textlocal->sendSms($numbers, $message, $sender);
print_r($response);
//echo $message;
}
}
$sql="SELECT * FROM admin
WHERE username NOT IN (
SELECT studentname
FROM transcation
WHERE MONTH(DATE(date))=MONTH(CURDATE())
)
and usertype='student' ";
$result= mysqli_query($conn, $sql)
or die($sql."<br/><br/>".mysql_error());
If(mysqli_num_rows($result)>0) {
while($row=mysqli_fetch_array($result)) {
$username=$row['username'];
echo $username;
$mobile=$row['mobile'];
$numbers=(explode(" ",$mobile));
foreach ($numbers as $item) {
echo $item;
}
这是我的命令:
/usr/local/bin/php /home/cpdarmkr/public_html/danceschool/message.php
一只名叫tom的猫
Smart猫小萌