<?php
//connect to mysql
$conn=@mysql_connect("localhost", "root", "")
or die("Could not connect to DB");
//select database
$rs = @mysql_select_db("dsm", $conn)
or die("could not select database");
$sql="DELETE FROM uploads WHERE filename = \"$file\"";
//execute the query
$rs=mysql_query ($sql,$conn);
echo("The file details have been found in database and deleted");
?>
///////////////////////////////////////
This is a simple script that searches a table called ‘uploads’ and deletes the record that contains a ‘filename’ called $file (where $file is a value passed in from a html form)
At the moment it echo's a message if the file exists and has deleted. But I want this script to be dynamic...
I want a different message output if no such record exists. Please can you direct me to the correct website or code?
I tried added these 2 statements:
if ($rs)
echo("The file details have been found in database and deleted");
if(!$rs)
echo("File not found in database");
but the first IF statement is always output. I really don’t know if I’m on the right lines, please help, been working on this since the morning and its now 1.33am!! I've given up :o(
..newbie for you