1 I want to give my users the ability to send a message to multiple users at one shot, meaning the $to variable is an array,
function write(){
global $username, $subject, $message, $to;
if ((!isset($to)) OR ($to=="")) {echo "<b>You did not specify a recipient</b>"; compose();}
else {
$toarray=explode (",", $to);
while (list($index, $toeach) = each ($toarray)){
$checkusermysql_query("select username from users where username = '$toeach'");
if ($checkuser){
$count=mysql_num_rows($checkuser);
if ($count==0) {echo "<b>Sorry, but $toeach not found</b>"; compose();}
if ($count==1) {
if ((!isset($subject)) OR ($subject=="")) $subject="No Subject";
if ((!isset($message)) OR ($message=="")) {echo "No Message to send"; compose(); }
else {
$to=strtolower($toeach);
$insert=mysql_query("insert into messages values (NULL, '$toeach', '$username', NOW(), '$subject', '$message', 'yes', 'no')");
if (!$insert) echo "Error inserting message: If this continues, contact the webmaster";
else showmessage();
unset($toeach);
}}
}}
if ($count>1) {echo "Error in user query, please try again"; compose(); }
}}
it inserts the first one okay, but it says it couldn't find the other ones. but if I only send to 1 user, the code works perfect any ideas why?
another problem is a filter system that i made, :
function filter($string){
global $username;
if ((!isset($username)) or ($username=="")) {
$querylist=mysql_query("select from filter where userid='master'");
$list=mysql_result($querylist, 0, 'content');
$listarray=explode(",", $list);
while (list($ArrayIndex, $ArrayContent) = each ($listarray))
{
$string=eregi_replace("$ArrayContent", " ** ", $string);
}
echo $string; }
else {
$querylist=mysql_query("select from filter where userid='$username'");
$list=mysql_result($querylist, 0, 'content');
$listarray=explode(",", $list);
while (list($ArrayIndex, $ArrayContent) = each ($listarray))
{
$string=eregi_replace("$ArrayContent", " ** ", $string);
}
echo $string;
}}
the problem is, it works fine unless the the person uses some word in the first word of the sentence, then it wont catch it, any ideas?