i have figured out this time
first i had <? php rather than <?php. i have fixed that and still had problems but at least the error message showed me that there was an error connecting to the database.
i deleted the password field in the following
$conn = mysql_connect("localhost", "root", " ")
or die('could not connect: '. mysql_error());
i made it
$conn = mysql_connect("localhost", "root")
or die('could not connect: '. mysql_error());
and now my script works and i am able to connect to mysql
i finally found out something else: because i don't have a password for the root account. the pasword shouldn't contain any characters including space so i did this:
$conn = mysql_connect("localhost", "root", "")
or die('could not connect: '. mysql_error());
this worked.
and finally finally, i created a password for my root account - all is fine now.