Author Topic: Fix for 'ERROR: The member you typed doesn't exist' errors  (Read 3819 times)

Offline Daniel15

Fix for 'ERROR: The member you typed doesn't exist' errors
« on: December 17, 2006, 11:20:44 am »
Since SMF 1.1 came out, the behavior of the 'Find Members' popup has changed. Basically, it puts quotation marks around the username, whereas SMF 1.0 didn't. Thus, on the Send Money to someone and Send item to someone pages, you may get errors like this:

ERROR: The member you typed ('\"Daniel15\"') doesn't exist

Here's the fix for SMFShop 2.3, so it works properly again. The development version will be fixed soon.
In Sources/shop/Shop-Send.php, find:
Code: [Select]
// Get the id and name of member to send to
$result = db_query("SELECT ID_MEMBER, memberName
FROM {$db_prefix}members
WHERE memberName = '{$_POST['membername']}'
LIMIT 1", __FILE__, __LINE__);
$row = mysql_fetch_array($result, MYSQL_ASSOC);

// If the member's name is not what the user posted... They don't exist!
if ($row['memberName'] !== $_POST['membername']) {
$context['shop_buy_message'] = sprintf($txt['shop_member_no_exist'], $_POST['membername']);

Replace with:
Code: [Select]
// This code from PersonalMessage.php, lines 1531-1535. It trims the " characters off the membername posted,
// and then puts all names into an array
$_POST['membername'] = strtr($_POST['membername'], array('\\"' => '"'));
preg_match_all('~"([^"]+)"~', $_POST['membername'], $matches);
$moneyArrayTo = array_unique(array_merge($matches[1], explode(',', preg_replace('~"([^"]+)"~', '', $_POST['membername']))));

// We only want the first memberName found
$moneyTo = $moneyArrayTo[0];

// Get the id and name of member to send to
$result = db_query("SELECT ID_MEMBER, memberName
FROM {$db_prefix}members
WHERE memberName = '{$moneyTo}'
LIMIT 1", __FILE__, __LINE__);
$row = mysql_fetch_array($result, MYSQL_ASSOC);

// No results? They don't exist!
if (mysql_num_rows($result) == 0) {
$context['shop_buy_message'] = sprintf($txt['shop_member_no_exist'], htmlentities($moneyTo));


Find:
Code: [Select]
// Get new owner's information
$result = db_query("SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE memberName = '{$_POST['membername']}'", __FILE__, __LINE__);
$rowNewOwner = mysql_fetch_array($result, MYSQL_ASSOC);

Replace with:
Code: [Select]
// This code from PersonalMessage.php, lines 1531-1535. It trims the " characters off the membername posted,
// and then puts all names into an array
$_POST['membername'] = strtr($_POST['membername'], array('\\"' => '"'));
preg_match_all('~"([^"]+)"~', $_POST['membername'], $matches);
$itemArrayTo = array_unique(array_merge($matches[1], explode(',', preg_replace('~"([^"]+)"~', '', $_POST['membername']))));

// We only want the first memberName found
$itemTo = $itemArrayTo[0];

// Get new owner's information
$result = db_query("SELECT ID_MEMBER
FROM {$db_prefix}members
WHERE memberName = '{$itemTo}'", __FILE__, __LINE__);
$rowNewOwner = mysql_fetch_array($result, MYSQL_ASSOC);

// No results? They don't exist!
if (mysql_num_rows($result) == 0) {
printf($txt['shop_member_no_exist'], htmlentities($_POST['membername']));
die();
}


Offline Illusion

Re: Fix for 'ERROR: The member you typed doesn't exist' errors
« Reply #1 on: December 18, 2006, 09:02:00 pm »
I did the changes, but still get:

ERROR: The member you typed ('Vortex') doesn't exist!

Offline Daniel15

Re: Fix for 'ERROR: The member you typed doesn't exist' errors
« Reply #2 on: December 20, 2006, 05:35:18 pm »
Are you sure that's the user's username, and not their display name? Do you get the same error with all users?

Offline Illusion

Re: Fix for 'ERROR: The member you typed doesn't exist' errors
« Reply #3 on: December 21, 2006, 04:14:12 am »
D'oh!

Got it there, it's because I was using their display name.

Can I change this to display name somehow, it's a little slow when I have to find their username as well.

Offline Daniel15

Re: Fix for 'ERROR: The member you typed doesn't exist' errors
« Reply #4 on: January 07, 2007, 08:04:01 pm »
Quote
Can I change this to display name somehow
When you click that little "Find Users" button next to the input box, you may type their display name into the popup box, click the Search button, and it will show their username. Click on it to insert it into the input box.
This works the same way as the SMF Send PMs section

Offline Daniel15

Re: Fix for 'ERROR: The member you typed doesn't exist' errors
« Reply #5 on: January 19, 2007, 07:07:00 pm »
Fixed in SMFShop 3.0, unstickyed