This is going bye-bye soon.
Added some error checking.
Multiple edits, starting over with sproc run.
Removed code that escapes input chars.
Multipe edits, especially trying to make mysqlGetPad() to successfully query the database. This code is broken and needs fixing.