PM's - multiple sends

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Aaron
Forum Commoner
Posts: 82
Joined: Sun May 12, 2002 2:51 pm

PM's - multiple sends

Post by Aaron »

Code: Select all

<?

	if(!$r_uid)
	{$error = "You must enter a username to send the PM to."; 
	$forward = "back";
	error_box($error, $forward);}

	elseif(!$title)
	{$error = "You must enter a title."; 
	$forward = "back";
	error_box($error, $forward);}

	elseif(!$message)
	{$error = "You must enter a message."; 
	$forward = "back";
	error_box($error, $forward);}
	
	elseif(mysql_fetch_row(mysql_query("SELECT uid, username FROM unz_users WHERE username = '$r_uid'"))) 
	{echo "success!";
//DO SEND HERE
}
	
	else
	
	{$error = "Somethings gone wrong!"; 
	$forward = "back";
	error_box($error, $forward);}

?>
The problem Im having is this; The user can put in multiple names to send the PM to, hence if I put more than one r_uid then theres no username with azz0r;john...Any help much appreciated.
User avatar
Kriek
Forum Contributor
Posts: 238
Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:

Post by Kriek »

Self-explanatory user-defined function ;)

Code: Select all

function makecommas($string) {
    if ($string == "") {
        return "''";
    } else {
        return str_replace(" ", ",", trim($string));
    }
}
Amended query to select all usernames.

Code: Select all

SELECT DISTINCT uid, username FROM unz_users WHERE username IN(".makecommas($r_uid).")
The result would be Jane, John, Jake, Jill ect.
Aaron
Forum Commoner
Posts: 82
Joined: Sun May 12, 2002 2:51 pm

Post by Aaron »

Thanks alot! /me licks
Aaron
Forum Commoner
Posts: 82
Joined: Sun May 12, 2002 2:51 pm

Post by Aaron »

ooo :/ I get this error

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/azz0r/public_html/pages/PM/replying.php on line 18 (link 18 being the query...)

Just tried this aswell (added an extra ")

Code: Select all

<?php
elseif(mysql_fetch_array(mysql_query("SELECT DISTINCT uid, username FROM unz_users WHERE username IN(".makecommas($r_uid).""))) 
?>
Same error still!
User avatar
Kriek
Forum Contributor
Posts: 238
Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:

Post by Kriek »

Count the parenthesis ;)

Code: Select all

elseif(mysql_fetch_array(mysql_query("SELECT DISTINCT uid, username FROM unz_users WHERE username IN(".makecommas($r_uid).")"))) {
Aaron
Forum Commoner
Posts: 82
Joined: Sun May 12, 2002 2:51 pm

Post by Aaron »

Still getting the same error :/
Post Reply