Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

database problem for a blocklist!

Posted on 2006-11-02
10
Medium Priority
?
173 Views
Last Modified: 2010-04-05
I got a small problem with a database statment I want to check a blocklist on my privmsg section for blocked users but when I try following code it dont check blocklist it till allows people to msg one and other even if name is in blocklist can anyone help fix the problem please?

thanks

[code]
if UsersTable.Locate('Name',dat[0],[locaseinsensitive])then // check my own account table
     begin
     if UsersTable.Locate('BlockedUsers',dat[1],[locaseinsensitive]) then // check my blocklist table
     begin

      if rSocket<>nil then
      if rSocket.Connected then
         rSocket.SendText(CodeStr('šTechMsgœERROR '+dat[0]+'œ')); // send error msg if name found in blocklist

   end
   else
   begin // if name not found then send msg!

rSocket.SendText(CodeStr('šRPrivMsgœOKœ'+dat[0]+'œ'+dat[3]+'œ'));
    s:='šPrivMsgœ'
          +dat[1]+'œ'  // MyName
          +dat[2]+'œ'  // There Name
          +dat[3]+'œ'; // Message
0
Comment
Question by:fiveuk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
10 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 17861952
If you are using "real" database do it with query inside the DB. For example:

SELECT * FROM privmsg
WHERE sender_id NOT IN
  ( SELECT user_id FROM blocked_user ...)

Something like this...
0
 

Author Comment

by:fiveuk
ID: 17862009
am using db its how the program been setup :( can you still help? allso my sql programing sucks
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 17862095
Give me some more info. Which tables you query, what fields they have and so on, so I can help you with the SQL query.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:fiveuk
ID: 17862154
this database

CREATE TABLE `users` (
  `N` int(11) NOT NULL auto_increment,
  `Name` varchar(32) default '',
  `Pass` varchar(16) default '',
  `BlockedUsers` text,
  PRIMARY KEY  (`N`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

all I want to do is check the persons database that I am sending a message to and if am on his blocklist my message will not be sent to him!

can you help?

so when I send message it would do following :

dat[0] (Simon)  -> Send msg -> server checks Blocklist of person dat[1] (bob) I am sending msg to and if my ID is in his block list it will send me the error msg if not then it will allow me to send msgs
0
 
LVL 12

Accepted Solution

by:
Ivanov_G earned 500 total points
ID: 17862290
My opinion is that your DB design is wrong. What will happen if you have 2 users in the blocklist? Maybe "bob1,bob2,etc"

I think you should do it this way:

Table: users
---------------------------
N
Name
Pass


Table: users_blocked
---------------------------
rel_id - relation ID, auto_increment
user_N - your user ID
ignored_user_N - ID for ignored user


Some example data:

user
-------
1 Simon asfkjafklasjflksajf
2 Peter asdkfjaklfjalsfasfk
3 Georgi asfjalksjfasjf;lajf

users_blocked
1 1 2
2 1 3

In this example user Simon has blocked users Peter and Georgi. Using a query it can be checked like this:

SELECT COUNT(*)
FROM users u, users_blocked ub
WHERE u.ignored_user_N = 'Simon' -- your user ID that will be checked for ignore
  AND u.N = ub.user_N
  AND u.Name = 'bob' -- user that you checked if he has ignored you

If the result is 1 (or more) the user ignored you, if it is 0 - you can send the message
0
 

Author Comment

by:fiveuk
ID: 17862366
ok am lost lol
0
 

Author Comment

by:fiveuk
ID: 17862428
I did say am a newbe at MYSQL?

dont no were to start or anything
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 17862609
MySQL is quite simple database. You can start with its online documentation:
http://dev.mysql.com/doc/refman/5.1/en/index.html
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question