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]
I have a problem when I try to delete a record from a table in my MySql db. I can update, add records to the same table. But when I try to delete, nothing happen, no errors. The stuff that happens are the same as should happen if it was deleted, but it doesn't get deleted. I have tried the php code on another server, and there it works as it should and deletes the stuff from the db. Could there be a permission thing with MySql, that says I can't delete records? Or something like that? Is there a way to check that? Like e.g. php info?
Php Code:Code: Select all
<?php
//connect to MySQL
$db="dbname";
$connect = mysql_connect('host', 'user', 'pass');
if (! $connect)
die("Couldn't connect to MySQL");
mysql_select_db($db , $connect) or die("Select Error: ".mysql_error());
$query = "SELECT * FROM newscat ORDER BY categn DESC LIMIT 0, 25";
$results = mysql_query($query)
or die(mysql_error());
while ($row = mysql_fetch_array($results)) {
extract($row);
echo "<a href=\"editcategory2.php?id=$newscat_id\" onclick=\"return confirm('Are you realy sure you want to edit this category?')\">Edit Category</a> - ";
echo "<b>$categn</b>";
echo " - <a href=\"editcategory.php?newscat_id2=$newscat_id&delete=1\" onclick=\"return confirm('Are you realy sure you want to delete this category?')\">Delete Category</a> ";
echo "<br>";
}
if($_GET['newscat_id2'] && $_GET['delete'] == "1") {
$sql = "DELETE FROM newscat WHERE newscat_id = $newscat_id2";
$result = mysql_query($sql);
echo "Thanks.";
}
?>Pimptastic | 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]