Q:

escaping mysql table not found

I have a script that continuously  connects to a database and then truncates table in a loop fashion. The script breaks if there is not table found. How do i escape this to enable it run to the end?
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
 $username =$row['user_name'];
 $url=$row['url'];
 //$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die("MySQL Error: " . mysql_error());
 $db = mysql_select_db("ghcomm") ;

mysql_query ("TRUNCATE settings") or die("error settings". mysql_error()); 
}

A:

Use IF EXISTS in your SQL. 
Just replace the last statement : 
mysql_query ("TRUNCATE settings") or die("error settings". mysql_error()); 

with : 
mysql_query ("TRUNCATE settings IF EXISTS settings") or die("error settings". mysql_error()); 

That way you never trigger the die("error settings...") part.
Hope this helps !

