我只想从客户表中收到一封电子邮件,然后向该电子邮件发送消息。我收到此错误“警告: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);
}
?>
答案 0 :(得分:5)
您正在建立myslqi
连接,但之后使用mysql_*
(无i
)功能。您应该使用所有mysqli
。
答案 1 :(得分:0)
您可以尝试以下代码:
while ($row = mysql_fetch_array($result)) {
要
while ($row = mysql_fetch_array($getusers)) {