Re: If syntax

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i think for unique alias u have keep

alias='$alias' ??

and also "if" statement will always be true as the mysql statement is always correct and will be executed . U have to check the result of query for whether there r ne aliases or not ...


On Sat, 1 Oct 2005, Ron Piggott wrote:

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();

}



--
*********************************************************************************************

	You wouldn't know an OS if it hit you in the face ...

						Linux Baby !

*********************************************************************************************

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux