Jump to content


Photo

Problem running a query


  • Please log in to reply
3 replies to this topic

#1 holowugz

holowugz
  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts

Posted 09 March 2006 - 05:04 PM

The problem i am having is this section of my script needs to query our forum database and check to see if a username exists.
The problem is if i check for a username that contains a . EG UFDF C.Reed , i get an error.

//if there is a user name and it is not blank then ...
if (isset($_POST['username']) and $_POST['username'] !== "") {
$colname_RS_Username = "-1";
//clean the username
$colname_RS_Username = (get_magic_quotes_gpc()) ? $_POST['username'] : addslashes($_POST['username']);
//select everything from the forum usertable where the username is our ewntered name
mysql_select_db($database_connPASSWORD, $connPASSWORD);
$query_RS_Username = sprintf("SELECT * FROM vb3_user WHERE username = '%s' AND usergroupid = 26", $colname_RS_Username);

I am not sure what to actually do from here, is ther a way i can make it so it just searched for the username and not try an process it if it has a "." in it.

#2 holowugz

holowugz
  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts

Posted 09 March 2006 - 06:07 PM

Ok i got it to work,

i just removed the AND usergroupid = 26

But does anyone know how i could rewrite that stsement to include :
AND usergroupid = 26

would appreciate any help cheers




#3 keeB

keeB
  • Staff Alumni
  • Advanced Member
  • 1,078 posts
  • LocationCalifornia

Posted 09 March 2006 - 07:08 PM

[!--quoteo(post=353319:date=Mar 9 2006, 06:07 PM:name=Luke Brown)--][div class=\'quotetop\']QUOTE(Luke Brown @ Mar 9 2006, 06:07 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I am not sure what to actually do from here, is ther a way i can make it so it just searched for the username and not try an process it if it has a "." in it.
[/quote]

Your query to the database can include like that.. take this theoretical statement..

select * from users 
where login not in ( select * from users where login like '%.%' )

Hope that helped.. ;)


Come visit my site to see my latest projects
http://nick.stinemates.org/wordpress/


#4 holowugz

holowugz
  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts

Posted 09 March 2006 - 07:22 PM

Ty for your reply,

i actually managed to get it working i just replaced the query with this:
$query_RS_Username = "SELECT * FROM vb3_user WHERE usergroupid = 26 AND username = '$colname_RS_Username'";

and it works now but ty for your reply.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users