loxinthe
January 2nd, 2008, 06:10
I have two files here to delete a record form a database, first:
<?
mysql_connect(localhost,$uname,$pword);
@mysql_select_db($db) or die( "Unable to select database");
$query="SELECT * FROM special";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
echo "<table>";
while ($i < $num) {
$title=mysql_result($result,$i,"title");
$pic=mysql_result($result,$i,"pic");
$description=mysql_result($result,$i,"description");
$expire=mysql_result($result,$i,"expire");
$valid=mysql_result($result,$i,"valid");
echo "<tr><td><b>$title</b></td>
<td rowspan='5'><img src=$pic></td></tr>
<tr><td>Description: $description</td></tr>
<tr><td>Expiration Date: $expire</td></tr>
<tr><td>Valid with other offers?: $valid</td></tr>";
echo "<tr><td colspan='2'><form ENCTYPE='multipart/form-data' method='post' action='editspecial.php'>
<input type='hidden' name='title' value=$title>
<input type='hidden' name='pic' value=$pic>
<input type='hidden' name='description' value=$description>
<input type='hidden' name='expire' value=$expire>
<input type='hidden' name='valid' value=$valid>
<input type='submit' value='Edit Special'>
</form>
<form ENCTYPE='multipart/form-data' method='post' action='deletespecial.php'>
<input type='hidden' name='title' value=$title>
<input type='hidden' name='pic' value=$pic>
<input type='hidden' name='description' value=$description>
<input type='hidden' name='expire' value=$expire>
<input type='hidden' name='valid' value=$valid>
<input type='submit' value='Delete Special'>
</form>
</td>
</tr>
<tr>
<td colspan='2'>
<br<hr><br>
</td>
</tr>";
$i++;
}
echo "</table>";
?>
Now here is deletespecial.php that the last files refers to when they click delete:
<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
$uname="<<removed>>";
$pword="<<removed>>";
$db="<<removed>>";
$title=$_POST['title'];
$pic=$_POST['pic'];
$description=$_POST['description'];
$expire=$_POST['expire'];
$valid=$_POST['valid'];
mysql_connect(localhost,$uname,$pword) or die("It's gone");
@mysql_select_db($db) or die( "Unable to select database");
$query = "DELETE FROM special WHERE title='$title',pic='$pic',description='$descriptio n',expire='$expire',valid='$valid'" or die ("It is still there!");
?>
<div align="center"><b>Record has been successfully deleted.</b></div>
I always get Record has been successfully deleted, but it isn't. Please Help.
<?
mysql_connect(localhost,$uname,$pword);
@mysql_select_db($db) or die( "Unable to select database");
$query="SELECT * FROM special";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
echo "<table>";
while ($i < $num) {
$title=mysql_result($result,$i,"title");
$pic=mysql_result($result,$i,"pic");
$description=mysql_result($result,$i,"description");
$expire=mysql_result($result,$i,"expire");
$valid=mysql_result($result,$i,"valid");
echo "<tr><td><b>$title</b></td>
<td rowspan='5'><img src=$pic></td></tr>
<tr><td>Description: $description</td></tr>
<tr><td>Expiration Date: $expire</td></tr>
<tr><td>Valid with other offers?: $valid</td></tr>";
echo "<tr><td colspan='2'><form ENCTYPE='multipart/form-data' method='post' action='editspecial.php'>
<input type='hidden' name='title' value=$title>
<input type='hidden' name='pic' value=$pic>
<input type='hidden' name='description' value=$description>
<input type='hidden' name='expire' value=$expire>
<input type='hidden' name='valid' value=$valid>
<input type='submit' value='Edit Special'>
</form>
<form ENCTYPE='multipart/form-data' method='post' action='deletespecial.php'>
<input type='hidden' name='title' value=$title>
<input type='hidden' name='pic' value=$pic>
<input type='hidden' name='description' value=$description>
<input type='hidden' name='expire' value=$expire>
<input type='hidden' name='valid' value=$valid>
<input type='submit' value='Delete Special'>
</form>
</td>
</tr>
<tr>
<td colspan='2'>
<br<hr><br>
</td>
</tr>";
$i++;
}
echo "</table>";
?>
Now here is deletespecial.php that the last files refers to when they click delete:
<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
$uname="<<removed>>";
$pword="<<removed>>";
$db="<<removed>>";
$title=$_POST['title'];
$pic=$_POST['pic'];
$description=$_POST['description'];
$expire=$_POST['expire'];
$valid=$_POST['valid'];
mysql_connect(localhost,$uname,$pword) or die("It's gone");
@mysql_select_db($db) or die( "Unable to select database");
$query = "DELETE FROM special WHERE title='$title',pic='$pic',description='$descriptio n',expire='$expire',valid='$valid'" or die ("It is still there!");
?>
<div align="center"><b>Record has been successfully deleted.</b></div>
I always get Record has been successfully deleted, but it isn't. Please Help.