Please login or register.

Login with username, password and session length
Advanced search  

News:

We are constantly trying to improve phpfreaks and these forums, so feel free to go to the PHPFreaks Comments/Suggestions board and point out anything you'd like to see different!

Maintenance Notice

PHPFreaks has successfully moved to a new Dedicated Server, hosted by Server Powered. Please help support future upgrades by Donating.

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

0 Members and 1 Guest are viewing this topic.

Perad

  • Member
  • Offline Offline
  • Posts: 232
    • 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

  • Administrator
  • **********
  • Online Online
  • Gender: Male
  • Posts: 14,982
    • View Profile
    • WWW
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

Currently reading Learning the Bash shell (again).
Debian :: Hudzilla :: Rute :: Howto Ask? :: My Blog :: My Git Repos
 

Page created in 0.054 seconds with 17 queries.