I have been creating a php webpage, I have created a section of code which deletes the uploaded information, although it does delete the actual item it doesnt delete the link supplied for the item, which has been written in my sql database
below is the code which does the deletion
if ($picDelete1 == "deleted")
{
$sql1="UPDATE lessondetails picture1 = '' WHERE r_id ='$pid'";
makeQuery($sql1);
if (!unlink($pic1))
{
echo ("Error deleting $file");
}
else
{
echo ("Deleted $file");
}
$picture1 = "";
}
and below this sentence is the code which connects to the database
?php
function makeQuery($query)
{
//build select query
$msg="";
//connect to mysql
if(!($database = mysql_connect("studb.cms.gre.ac.uk","dd615","army4sr")))
{
$msg+="could not connect to database<br/>";
}
if(!mysql_select_db("mdb_dd615",$database))
{
$msg+="could not open database<br/>";
}
if(!($result = mysql_query($query,$database)))
{
$msg+="could not execute query:".mysql_error()."<br/>";
}
mysql_close($database);
return $result;
}
?>