Location: PHPKode > projects > PHP MySQL Address Book > addressbook/library/delrec.php
<?php
if(! isset($_SESSION['sectors'])){
    session_start();
    // include("conf/conf.php");
   /* $databaseURL = 'localhost';//$dbConf->get_databaseURL();
    $databaseUName = 'root';//$dbConf->get_databaseUName();
    $databasePWord = '';//$dbConf->get_databasePWord();
    $databaseName = 'addrnew';//$dbConf->get_databaseName();
*/
include 'config.php';
//    $dbConf = new AAConf();
    $databaseURL =$dbhost;// 'localhost';//$dbConf->get_databaseURL();
    $databaseUName = $dbuser;//'root';//$dbConf->get_databaseUName();
    $databasePWord = $dbpass;//'';//$dbConf->get_databasePWord();
    $databaseName = $dbname;// 'addrnew';//$dbConf->get_databaseName();
    //Set DB Info. in-session
 /*   $_SESSION['databaseURL']=$databaseURL;
    $_SESSION['databaseUName']=$databaseUName;
    $_SESSION['databasePWord']=$databasePWord;
    $_SESSION['databaseName']=$databaseName;

*/

    $connection = mysql_connect($databaseURL,$databaseUName,$databasePWord);
    if (!$connection)
    {
        die('Could not connect: ' . mysql_error());
    }
    // or die ("Error while connecting to localhost");
    $db = mysql_select_db($databaseName,$connection);
    //or die ("Error while connecting to database");

    $sql="delete from contacts WHERE id=".$_GET['ID'];
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8'); 
    if (!mysql_query($sql,$connection))
    {
        die('Error: ' . mysql_error());
    }
	
	
	$imgquery = "SELECT `imagename`  FROM `tblimages` WHERE id =" .$_GET['ID'];
mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8'); 

$imgresult = mysql_query($imgquery);
//$row = mysql_fetch_array($imgresult, MYSQL_ASSOC);
		if (mysql_num_rows($imgresult)>0)
		{
		
				while($imgrow = mysql_fetch_array($imgresult))
				{
				if (trim($imgrow['imagename'])!=="")
						{
						 unlink("../uploads/".trim($imgrow['imagename']));
						 }
				}
		}
	
	
	
	
	 
$sqlimg="delete from `tblimages` WHERE id=".$_GET['ID'];

mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8'); 
    if (!mysql_query($sqlimg,$connection))
    {
        die('Error: ' . mysql_error());
    }

	
	
//    echo "Contact deleted";
    mysql_close($connection);
    header('Location: ../dtaildaddresscard.php?type=sort&value='.$_GET['salph']);
    exit;

}

header('Location: ../dtaildaddresscard.php?type=sort&value='.$_GET['salph']);
    exit;
?>
Return current item: PHP MySQL Address Book