Solved

database problem for a blocklist!

Posted on 2006-11-02
10
167 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
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now