Did you try to replace localhost with 127.0.0.1?
edit (added question): Is the error really 'Unknown MYSQL server host ' localhost' <11004>', as in '<space>localhost? Could it be your code is not actually what you pasted, and the is a space before $hostname?
In reply to Re^3: connect to DBD::MYSQL
by Tux
in thread connect to DBD::MYSQL
by fionbarr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |