0

我只想从客户表中获取一封电子邮件并将消息发送到该电子邮件。我收到此错误

“警告:mysql_num_rows() 期望参数 1 是”

我的代码如下:

<?php
       $mysql = mysql_connect("localhost", "hname", "passs", "dbname");

       $getusers = mysql_query("SELECT * FROM customer");
       while ($row = mysql_fetch_array($result)) {
       sendMail($row['email']);
       }
       mysql_free_result($result);
       function sendMail($to){
       $subject = 'the subject';
       $message = 'hello';
       $headers = 'From: webmaster@example.com' . "\r\n" .
       'Reply-To: webmaster@example.com' . "\r\n" .
       'X-Mailer: PHP/' . phpversion();
       mail($to, $subject, $message, $headers);
       }
?>
4

2 回答 2

5

您正在建立myslqi连接,但随后使用mysql_*(no i) 功能。你应该使用所有mysqli.

于 2013-01-29T00:19:58.257 回答
0

你可以试试这段代码:

while ($row = mysql_fetch_array($result)) {

while ($row = mysql_fetch_array($getusers)) {
于 2013-01-29T05:35:39.910 回答