Re: executing an SQL statement
There are a few of things that may be happening.
First, if you are not using a fixed width font (like courier) to view the data, the columns won't line up no matter what you do. If you are viewing the result as html wrap the ouput in <pre></pre> tags.
Second, if the fields are longer than the width you specify, the data will be truncated and no spaces will be added.
Third, if you are using a version prior to 4.1 and your select requires temporary tables, the RPAD() function will not work as expected--no spaces will be added.
Can you post a sample of your output? A couple of lines will probably do.
As far as including multiple statements in $dbh->prepare(), my version won't do that. Maybe a newer version will. My guess is that, since you've tried it, it won't work.