Sounds like you just need to flip the order of your arguments here...
concat('$lastline', lastline)
Side note: mysql_*
methods are deprecated, you should switch to mysqli
or PDO
as soon as possible. Then look at prepared statements with bound parameters, so you aren't so open to SQL injection.