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

0 Members and 1 Guest are viewing this topic.

Offline PeradTopic starter

  • Enthusiast
    • View Profile
[SOLVED] Simple MySQL problem
« on: May 02, 2007, 11: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;
}

Offline thorpe

  • Staff Alumni
  • 'Mind Boggling!'
  • *
    • View Profile
Re: Simple MySQL problem
« Reply #1 on: May 02, 2007, 11: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;
  }
}

?>

Patience is like bread I say, I ran out of that yesterday.

Debian :: Funtoo :: Hudzilla :: Rute :: How To Ask?

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.