Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

database problem for a blocklist!

Posted on 2006-11-02
10
Medium Priority
?
174 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
  • 4
  • 4
8 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 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

Independent Software Vendors: 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!

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

876 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