Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi everyone,
Thanks for reading my post - I have a problem with a script of mine... I don't exactly know whats wrong - I've done this type of script millions of times, but something just isn't working. Here's the deal: It is a deletion confirmation page, and when I click yes to confirm the delete (in which it should direct to the beginning of the PHP script and follow after the if(isset thing...) However, this is the error message I get:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Here is the actual button from the confirmation page (HTML)Code: Select all
Are you sure you want to delete <? echo "$fl_title"; ?> by <? echo "$fl_artist"; ?>?
<form action="<?= $_SERVER['PHP_SELF'] ?>" enctype="multipart/form-data" method="post">
<input name="del_file" value="<? echo $id; ?>" type="hidden">
<INPUT type="submit" value="confirm"></form>
<form method="post" action="index2.php">
<INPUT type="submit" value="cancel"></form>Code: Select all
<?php
include("connect.php");
$sql = "SELECT fl_title, fl_artist, fl_loc FROM fruityloops WHERE fl_id=$id";
$result = @mysql_query($sql,$connection) or die(mysql_error());
$num = mysql_num_rows($result);
if($num >= 1)
{
while ($row = mysql_fetch_array($result))
{
$fl_title = stripslashes($row['fl_title']);
$fl_artist = stripslashes($row['fl_artist']);
$fl_loc = $row['fl_loc'];
}
}
///////////////////////////////////////////////////
// DELETE SELECTED MP3
///////////////////////////////////////////////////
if(isset($_POST[del_file]))
{
$sql = "SELECT * FROM fruityloops WHERE fl_id='$_POST[del_file]'";
$result = @mysql_query($sql,$connection) or die(mysql_error());
while ($row = mysql_fetch_array($result))
{
$fl_loc = $row['fl_loc'];
}
if(file_exists($fl_loc))
{
unlink($fl_loc);
} else {
echo '<script>alert("The file does not exist.");</script>';
echo '<META http-equiv="refresh" content="0;URL=index2.php">';
exit;
}
$sql = "DELETE FROM fruityloops WHERE fl_id=$del_file";
$result = @mysql_query($sql,$connection) or die(mysql_error());
echo '<script>alert("File Deleted Successfully!");</script>';
echo '<META http-equiv="refresh" content="0;URL=index2.php">';
exit;
}
?>Thanks for your help,
- Jeff
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]