Well, throw in some more tests, I guess. Remove the "@" up there ... not sure, but I think error suppression wouldn't allow the die() statement to work there ... might be wrong. OTOH, I'm sure it's generally a bad idea to use "@" when debugging, like we are here.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Cp1252">
<title>phptest</title>
</head>
<body>
test1
<?php
echo "test2";
$username='XXXX';
$password='XXXX';
$database='XXXX;
echo "test3";
$conn=mysql_connect("localhost","$username","$password") or die ("cant connect".mysql_error());
if (!$conn) die("Dying: connect variable returned false");
echo "test4";
$sel=mysql_select_db($database,$conn) or die("oops, sql died".mysql_error());
if (!$sel) die("Dying: select variable returned false");
echo "test5";
$query = "SELECT path FROM files";
$result=mysql_query($query);
if (!$result) die("Dying: result variable returned false");
$num=mysql_numrows($result);
if (!$num) die("Dying: numrows call returned false");
$i=0;
echo "test6 $i";
while ($i < $num) {
$path=mysql_result($result,$i,"path");
echo "<b>$path<hr><br>";
$i++;
}
?>
test7
</body>
</html>
Hmm, if you can connect in the shell, but not here, is there something wrong in php.ini??