Im writing some code to send out emails for work. And i've been stuck on with this error for a while nw. Any help will be greatly appreciated.

Error message: Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\PHP\mailMany.php on line 21

Heres my code:

// Check, if submitted.

// Get variables from POST method form.

$sender=""; // Your Email here.

echo "Email has been sent to:";

// Connect database

$rs=mysql_query("select CommercialEnterprise_Email from commercialenterprise WHERE 'town' = 'Killkee'");

// Do while loop to send email.

The Line below is where error is.

$mail_from="From:$email n";
$mail_from .="Content-Type: text/html; charset=utf-8 n";


// Show sent emails.
echo "$row[email]<br>";

// Do following codes if not found "Submit" value.(Not submitted)
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Form</title>
<form action="<? echo $PHP_SELF; ?>" method="post" name="form" id="form">
<td align="right">Subject : </td>
<td><input name="email" type="text" id="email" /></td>
<td align="right" valign="top">Note : </td>
<td><textarea name="comment" cols="60" rows="5" id="comment"></textarea></td>
<input type="submit" name="Submit" value="Send Email" />
<?php } ?>

Thanks in advance :)

Recommended Answers

All 2 Replies

Replace the quotes that surrounds the field name 'town' with back ticks, so this:

$rs=mysql_query("select CommercialEnterprise_Email from commercialenterprise WHERE 'town' = 'Killkee'");


$rs=mysql_query("select CommercialEnterprise_Email from commercialenterprise WHERE `town` = 'Killkee'");

If you still get errors add mysql_error():

Am assuming that your line 21 is the select statement, ryt?? If so, then your query should be;

$rs=mysql_query("select CommercialEnterprise_Email from commercialenterprise WHERE town = 'Killkee'");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.