I can't make any sense out of that.
What is the point of your $sql
variable? You never use it.
Where does $result come from? You didn't bother to show that.
And this makes me really nervous:
... so far created a couple of databases...
Why would you need more than one database??? Multiple tables, perhaps. Likely, even. But multiple databases