Hi jamal,
Try something along these lines - I think you're making this perhaps a little more complicated than you need to.
I assume this is your line to connect to your server:
$link=mysql_connect("localhost","motn","82dh435f7848f");
If that is the case, why are you calling it when you try and select your db here?:
if(mysql_select_db("MOTN", $link)){
If you're after errors, try this:
mysql_connect ('localhost', 'motn', '82dh435f7848f') or die ('Unable to Connect');
mysql_select_db('motn') or die ('Unable to select database');
You're getting the invalid resource error because it's failing to connect to the database - if it can't connect to the database then your $q variable will be failing, if $q is failing, then obviously print_r($q) won't work either.