douguan3470 2018-05-04 08:48
浏览 41

在循环中使用curl从数据库中提取的数字向客户端发送数据

$text="text.";
//fetch from DB
$sql=mysql_query("SELECT * FROM `employee`");
while($query=mysql_fetch_array($sql))
{
  echo $employee_mobile=$query['employee_mobile'];
  echo $url="http://mobile.ssexpertcompu.com/vendorsms/pushsms.aspx?user=MYUSERNAME&password=MYPASSWORD&msisdn=".$employee_salary."&sid=78NSL&msg=".$text."&fl=0&gwid=2";

    $url = str_replace(" ","%20",$url); // to properly format the url 
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    echo $data = curl_exec($ch);
    curl_close($ch);
} 

First employee record are fetched from DB,then using curl I'm sending message to their respective mobile numbers.The code for sending messages works fine without loop. I've seen some post how to use curl in a loop, but couldn't modify to my needs.

  • 写回答

1条回答 默认 最新

  • dpblwmh5218 2019-08-07 10:16
    关注

    Looks like you have not defined $employee_salary and should exchange it with $employee_mobile:

    echo $employee_mobile = $query['employee_mobile'];
    echo $url = "http://mobile.ssexpertcompu.com/vendorsms/pushsms.aspx?user=MYUSERNAME&password=MYPASSWORD&msisdn=" . $employee_mobile . "&sid=78NSL&msg=" . $text . "&fl=0&gwid=2";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 对于这个复杂问题的解释说明
  • ¥50 三种调度算法报错 采用的你的方案
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败