0

我正在尝试向多个收件人发送短信。我试图实现这一点的代码是这样的:我面临的问题是消息仅传递到表中的第一条记录。

需要一些帮助,我哪里出错了?

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$result = mysql_query("SELECT name,mobile FROM members");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
while($row = mysql_fetch_row($result)) {
$mobile=$row[1];
$name=$row[0];

$request = "";
$param['mobileno'] = "91". $mobile;
$param['message']  = "Dear $name (organisation name) wishes you a very very Happy Birthday";
$param['username'] = "username";
$param['password']  = "password";
$param['sendername'] = "sender";
foreach ($param as $key => $val ){$request .= $key . "=" . urlencode($val);    
$request .= "&";}$request = substr( $request, 0, strlen( $request ) - 1 );
$url = "http://smsapi" . $request;
$ch = curl_init($url);curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
$result = curl_exec($ch);
var_dump($result);exit;
curl_close( $ch );
}
4

1 回答 1

0

您需要遵守 Joomla 编码标准。不要使用mysql_*功能,因为它们已被弃用并构成安全威胁。

$db = JFactory::getDbo();     
$query = $db->getQuery(true);    
$query->select('*')
->from('members');     
$db->setQuery($query);     
$rows = $db->loadObjectList();

while($rows){
    foreach ( $rows as $row ) {
        $mobile = $row->mobile;
        $name = $row->name;
    }

    //rest of code
}
于 2013-08-20T21:02:42.603 回答