Hey everybody. So I am just trying to write a script to delete a row in a MySQL database. Unfortunately I seem to have something wrong...even though I don't get any errors.

Here is a snippet of the code on the page to send the request:

echo "<tr><td width='138px' height='104px' valign='middle' rowspan='4'>" .
    "<img src='../$amv_thumbnail' border='0' align='center' /></td>" .
    "<td>$amv_name</td>" .
    "<td>$amv_length</td>" .
    "<td>$amv_creator</td>" .
    "<td>$amv_studio</td></tr>" .
    "<tr><td colspan='4'>$amv_url</td></tr>" .
    "<tr><td colspan='4'>$amv_creator_url</td></tr>" .
    "<tr><td colspan='4'><div style='text-align: right;'>" .
    "<a href='javascript:void(0)' onClick='javascript:sendRequest(\"deleterow.php?id=" .   $id . "\", \"viewer\")'>Remove AMV</a></div></td></tr>";

I have checked that the 'id' that was passed was correct. So I know that the code above is working. 'is' is not displayed as a variable above as it isn't directly used in the table. SELECT id, ... FROM amvs...while(list($id,...))

Here is the code from the deleterow.php script:


$dbc = mysqli_connect('server', 'username', 'password', 'database')
or die('Error  connecting to MySQL server.');

$id = $_GET['id'];
die("No ID passed");

$sql = "DELETE FROM amvs WHERE id='$id'";
$result = mysqli_query($sql)
or die('Error Deleting Record');

Echo "AMV Removed Successfully";

include_once 'getamvs.php';



The only message I get (plus the included page) is AMV Removed Successfully. However if I go to my phpMyAdmin the row is still there and it also shows up in the returned query below the message.

Can someone see something that I'm not?

LoL seems my server was just having a heart attack. Plus I forgot one tiny piece of code.

$result = mysqli_query($dbc, $sql)
or die('Error Deleting Record');

All is good now. Hope my find help someone else out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.