Yeah i consider it a pretty tough topic for which even if you have searched google or different search engines there's hardly few results that are correct.
As the same situation happened with me that's why i think since it is a thing you should know then why not post it.
NOTE : this code just deletes data from the database not a file.for deleting file you have to use unlink function.
Traditional method or taught by your teachers(might work sometime) :
<?php
$filename=$_GET['name']; //varible passed from last file
//echo $filename."<br/>"; //was for testing purpose
mysql_connect("localhost","root","");
mysql_select_db('test1');//selecting database
$query="DELETE FROM deposit WHERE file=".$filename;//deletes from the table named deposit where it //finds that if filename = the passed file name.
if(mysql_query($query))//loop for succesful or unsuccessful delete debugging
echo "delete succesful";
else
echo "not deleted";
mysql_close();//closing the connection
//header('Location:http://localhost/saharsh%20projects/filerepository/deposit.html');//redirection if needed/omit this if you want to see the result first
?>
What happens that for some of you this might not work and it must be showing delete unsuccesful.
New and corrected code for the same
<?php
$filename=$_GET['name'];
//echo $filename."<br/>";
mysql_connect("localhost","root","");
mysql_select_db('test1');
$query="DELETE FROM deposit WHERE file='$filename' ";
//changes are here the variable is now in //single quotes,rest everything is same.
//so that handler parses the variable correctly.
if(mysql_query($query))
echo "delete succesful";
else
echo "not deleted";
mysql_close();
header('Location:http://localhost/saharsh%20projects/filerepository/deposit.html');
?>
Hope it helped you ,
comments, suggestion ,your corrections or experiments on this are whole heartedly welcomed
As the same situation happened with me that's why i think since it is a thing you should know then why not post it.
NOTE : this code just deletes data from the database not a file.for deleting file you have to use unlink function.
Traditional method or taught by your teachers(might work sometime) :
<?php
$filename=$_GET['name']; //varible passed from last file
//echo $filename."<br/>"; //was for testing purpose
mysql_connect("localhost","root","");
mysql_select_db('test1');//selecting database
$query="DELETE FROM deposit WHERE file=".$filename;//deletes from the table named deposit where it //finds that if filename = the passed file name.
if(mysql_query($query))//loop for succesful or unsuccessful delete debugging
echo "delete succesful";
else
echo "not deleted";
mysql_close();//closing the connection
//header('Location:http://localhost/saharsh%20projects/filerepository/deposit.html');//redirection if needed/omit this if you want to see the result first
?>
What happens that for some of you this might not work and it must be showing delete unsuccesful.
New and corrected code for the same
<?php
$filename=$_GET['name'];
//echo $filename."<br/>";
mysql_connect("localhost","root","");
mysql_select_db('test1');
$query="DELETE FROM deposit WHERE file='$filename' ";
//changes are here the variable is now in //single quotes,rest everything is same.
//so that handler parses the variable correctly.
if(mysql_query($query))
echo "delete succesful";
else
echo "not deleted";
mysql_close();
header('Location:http://localhost/saharsh%20projects/filerepository/deposit.html');
?>
Hope it helped you ,
comments, suggestion ,your corrections or experiments on this are whole heartedly welcomed
Your Fxtm Review Account Allows You To Login To Your Account In More Than 1 Country.
ReplyDeleteVery useful articale. Thanks for sharing this with us. You can also check my website.
ReplyDeleteDownload Latest Mod Apk