我无法使用以下代码发送批量短信

时间:2012-06-06 15:21:47

标签: php mysql kannel

我是PHP和MySQL的新手我已经编写了下面的代码,以便能够发送批量短信,其中电话号码被选为数据库,电话号码位于不同的表中,使用表格选择它们但不是能够发送批量短信的任何帮助将受到高度赞赏。         

     if (!$con)
     {
     die('Could not connect: ' . mysql_error());
      }

       mysql_select_db("demo_forum", $con);

       if($result = mysql_query("SELECT phn_number FROM gen");
  ($row = mysql_fetch_array($result))

       elseif ($result = mysql_query("SELECT phn_number FROM tec"); 
  ($row = mysql_fetch_array($result))

  elseif ($result = mysql_query("SELECT phn_number FROM news"); 
    ($row = mysql_fetch_array($result))

   elseif ($result = mysql_query("SELECT phn_number FROM pol");
    ($row = mysql_fetch_array($result))

   else ($result = mysql_query("SELECT phn_number FROM pol, gen, news, tec"); 
    ($row = mysql_fetch_array($result))

     function sendSmsMessage($phn_number, $message)
      {
     $ch= curl_init();curl_setopt($ch, "http://$gw_host/process_sm/sendsms.php?to=$phn_numbermessage=.urlencode($message");
      curl_exec($ch);
      curl_close($ch);

       }

1 个答案:

答案 0 :(得分:1)

 $ch= curl_init();curl_setopt($ch, "http://$gw_host/process_sm/sendsms.php?to=$phn_numbermessage=.urlencode($message");

缺少ampersand (&)分隔查询字符串中的不同字段,而您的字符串包含文字.urlencode($message,因为您错误地放置了第二个

 $ch= curl_init();curl_setopt($ch, "http://$gw_host/process_sm/sendsms.php?to=$phn_number&message=" . urlencode($message));