You need quotes around $username in your SQL query, unless you've already run
$username thorough $dbh->quote();
j----- k-----
On Tuesday 04 March 2003 13:11, Jianping Zhu wrote:
> I am writing a simple login system by using perl( this is almost my first
> program in perl), After user pick a username i need to check if this
> username already exsited in mysql database table. if it is already in
> the table, this program will prompt user to pick another user name.
> but something wrong with following code, the program does not work.
>
>
>
> [code piece]***************************************
> my $selsql="SELECT * FROM apidbusers WHERE username=$username";
> #prepare the query for $selsql
>
> my $selsth=$dbh->prepare($selsql);
> $selsth->execute();
> if($selsth->fetchrow_array()) #*username already in apidbusers
> {
> print h4("This user name already registerd, please select
> another user name.");
> regstrForm();
> return;
> }
> ***********************************************************************
>
> How to fix this problem?
> Any suggesion is appreciated.
> J.P.
--
Joshua Kugler, Information Services Director
Associated Students of the University of Alaska Fairbanks
[EMAIL PROTECTED], 907-474-7601
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php