Solved

database problem for a blocklist!

Posted on 2006-11-02
10
171 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 125 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

734 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