Page 1 of 1

PM's - multiple sends

Posted: Sat Aug 09, 2003 9:37 am
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.

Posted: Sat Aug 09, 2003 10:36 am
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.

Posted: Sat Aug 09, 2003 12:41 pm
by Aaron
Thanks alot! /me licks

Posted: Sat Aug 09, 2003 12:47 pm
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!

Posted: Sat Aug 09, 2003 9:14 pm
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).")"))) {

Posted: Mon Aug 11, 2003 8:55 am
by Aaron
Still getting the same error :/