Please login or register.

Login with username, password and session length
Advanced search  

News:

(2009-05-04) The Rules and Terms of Service have been updated. Please make sure you read, understand, and follow them.

Author Topic: [SOLVED] Simple MySQL problem  (Read 278 times)

Active users: Perad (1), thorpe (1)
0 Members and 1 Guest are viewing this topic.

Perad

  • Enthusiast
  • Offline Offline
  • Posts: 241
    • View Profile
[SOLVED] Simple MySQL problem
« on: May 02, 2007, 10:38:31 AM »
This is to check if the user Alias is already taken. However if the name is in there or not it still returns the error saying it is. What can i change so it only flags up when the user actually isn't in there.

Code: [Select]
$sql="SELECT * FROM blog_members WHERE user_alias='$this->userAlias'";
$result = mysql_query($sql);
if ($result) {
echo " - Error 5005 - This username is taken!";
$this->error[] = 1;
}
Logged

thorpe

  • 'Mind Boggling!'
  • Offline Offline
  • Posts: 17,544
    • View Profile
Re: Simple MySQL problem
« Reply #1 on: May 02, 2007, 10:39:53 AM »
Code: [Select]
<?php

$sql
="SELECT * FROM blog_members WHERE user_alias='$this->userAlias'";
$result mysql_query($sql);
if (
$result) {
  if (
mysql_num_rows($result)) {
echo " - Error 5005 - This username is taken!";
$this->error[] = 1;
  }
}

?>

Logged

PHP Freaks Forums

 
 
 

Page created in 0.04 seconds with 20 queries.