If syntax
| From: | Ron Piggott | Date: | Sun, 02 Oct 2005 03:28:46 +0000 |
| Subject: | If syntax | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-40442@lists.php.net to get a copy of this message | ||
Take a look at my if ( ) syntax line below. I am wondering if I have it
wrong in same way. What I am trying to achieve is if the alias the user
enters is already found in the database I want the words "Alias already in
use" to be shown on the screen; otherwise "Unique alias" to be shown on the
screen.
PRESENTLY alias already in use is what comes up all the time.
Ron
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM tablename WHERE alias LIKE '$alias%'";
if (mysql_query($query))
{
echo "Alias already in use";
} else {
echo "Unique alias";
mysql_close();
}