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());
}
Use
IF EXISTSin your SQL.Just replace the last statement :
with :
That way you never trigger the
die("error settings...")part.Hope this helps !