Gossamer Forum
Home : General : Perl Programming :

Returns the rightmost len characters from the string str?

Quote Reply
Returns the rightmost len characters from the string str?
I need to extract last digit number from NAME From Mysql table Talbe_recipient, however it seems that script return nothing. Is there anyther wrong?

--------------------------------
$sql_syntax = qq(SELECT ID, recipID, NAME, RIGHT(NAME,1) AS age FROM $table_recipient WHERE ( Sender_ID ='$sender_ID') );

&SQL_EXE($dbh,$sql_syntax);

my( $ID, $recipID, $NAME, $age);

$sth->bind_columns( undef, \$ID, \$recipID, \$age);

print<<"[HTML]";
$age
[HTML]

-----------------------------

Thanks in advance

Quote Reply
added infos In reply to
#-----below code are work fine when i test it ( just take out "RIGHT(NAME,1) AS age " from the code---------------
$sql_syntax = qq(SELECT ID, recipID, NAME FROM $table_recipient WHERE ( Sender_ID ='$sender_ID') );

&SQL_EXE($dbh,$sql_syntax);

my( $ID, $recipID, $NAME);

$sth->bind_columns( undef, \$ID, \$recipID);

print<<"[HTML]";
$NAME
[HTML]
# The scritp print out a list NAME field value sucessful
#-----code end------------------------