while循环/ php中的函数

时间:2018-02-05 07:54:04

标签: php mysql function while-loop

我必须向一些用户发送私信。因此,我选择了数据库:

$sql = "SELECT * FROM `phpbb3_users` WHERE `user_email` LIKE '%testmail@online.com%'"; 

$result = $db->sql_query($sql);

选择有17个结果。

然后我使用此函数向每个user_id发送一条私人消息

include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);

function sendphpbbpm($pmmessage,$mid,$pmsubject) {

global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx;

$message = utf8_normalize_nfc($pmmessage);
$uid = $bitfield = $options = ''; // will be modified by 
generate_text_for_storage
$allow_bbcode = $allow_smilies = true;
$allow_urls = true;
generate_text_for_storage($message, $uid, $bitfield, $options, 
$allow_bbcode, $allow_urls, $allow_smilies);
$pm_data = array(
'from_user_id'      => '45148', //Community
'from_user_ip'      => '127.0.0.1',
'from_username'     => 'Community',
'enable_sig'        => false,
'enable_bbcode'     => true,
'enable_smilies'    => true,
'enable_urls'       => false,
'icon_id'           => 0,
'bbcode_bitfield'   => $bitfield,
'bbcode_uid'        => $uid,
'message'            => $message,
'address_list'        => array('u' => array($mid => 'to')),
 );

//Now We Have All Data Lets Send The PM!!
submit_pm('post', $pmsubject, $pm_data, false, false);
}

在while循环中我使用函数调用:

while ($row = $db->sql_fetchrow($result))
{

$mid = $row['user_id'];
$pmsubject = 'Test Subject';
$pmmessage = 'Test';

sendphpbbpm($pmmessage,$mid,$pmsubject);

}

问题是:只有第一个user_id获取私人消息而没有其他人。任何想法?

0 个答案:

没有答案