Many people may use this:
Code:
$sql = "SELECT * FROM table";
$result = mysql_query($sql);
if (!$result)
    die ("<b>SQL: </b> $sql<br /><b>Error: </b>" . mysql_error());
Shorter Version:
Code:
if (!$result = mysql_query($sql = "SELECT * FROM table"))
    die ("<b>SQL: </b> $sql<br /><b>Error: </b>" . mysql_error());