You can check whether the query was successful
//sql query here....
if ($query){
//display data...
}else{
//display error message
}
or else... check the number of rows the query returns... mysql_num_rows()
I am not sure whether this is effective, just give an idea.