Jump to content

Problem running a query


holowugz

Recommended Posts

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.
Link to comment
Share on other sites

[!--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) [snapback]353319[/snapback][/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..

[code]
select * from users
where login not in ( select * from users where login like '%.%' )
[/code]

Hope that helped.. ;)

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.