Browser problem or code problem?
Ok, so I have the following code, meant to delete a category in a script I'm working on. It takes the category ID from the $_GET array, checks the database to make sure such a category ID exists, then deletes it if true or shows an error if false.
When I execute this code, Firefox will always tell me that there is no category with the ID number specified, even when it does exist - however it will delete the category anyway. Opera does things correctly - a category is selected for deletion and the success message is shown.
Is this a browser problem or a code problem? I have tried all sorts of different solutions, originally the code was as such:
However I switched it around thinking that maybe Firefox was taking too long to check the category and then finding it deleted or something like that.
I haven't been able to test this in IE yet, but I have a feeling it might work, like it did in Opera. So... any ideas as to why it's not working in Firefox?
Specs: PHP 5.0.5/MySQL 5.0.15 running on Windows XP (local testing server); Firefox 1.5
Thanks in advance.
PS: First post to this community! *Bows low*
Edit: Solved! Firefox didn't like having a button in the form field used to get the delete ID (it's a "get" method form). Changed it to a normal link and everything now seems to be working as it should. :)
if ($_GET['categories'] == "deletecat") {
if (isset($_GET['delid'])) {
$idofd = cleaninput($_GET['delid'], 1);
$idofd = (int)$idofd;
$check_delete = mysql_fetch_assoc(mysql_query("SELECT * FROM table_cats WHERE cat_id = '" . $idofd . "' LIMIT 1", $connect));
if (empty($check_delete)) {
echo "<p><strong>Error:</strong> There is no category with the ID number " . $idofd . ".</p>";
}
else {
$deletecateg = mysql_query("DELETE FROM table_cats WHERE cat_id = '" . $idofd . "' LIMIT 1", $connect);
if ($deletecateg) {
echo "<p>The category was successfully deleted.</p>
<p><a href=\"" . $_SERVER['PHP_SELF'] . "\" title=\"Back to the main page\">Go back</a></p>";
}
else {
echo "<p>The category could not be deleted: " . mysql_error($connect) . "</p>";
}
}
}
else {
echo "<p><strong>Error:</strong> No category selected for deletion.</p>";
}
}When I execute this code, Firefox will always tell me that there is no category with the ID number specified, even when it does exist - however it will delete the category anyway. Opera does things correctly - a category is selected for deletion and the success message is shown.
Is this a browser problem or a code problem? I have tried all sorts of different solutions, originally the code was as such:
if (!empty($check_delete)) {
// delete the category
}
else {
// display error
}However I switched it around thinking that maybe Firefox was taking too long to check the category and then finding it deleted or something like that.
I haven't been able to test this in IE yet, but I have a feeling it might work, like it did in Opera. So... any ideas as to why it's not working in Firefox?
Specs: PHP 5.0.5/MySQL 5.0.15 running on Windows XP (local testing server); Firefox 1.5
Thanks in advance.
PS: First post to this community! *Bows low*
Edit: Solved! Firefox didn't like having a button in the form field used to get the delete ID (it's a "get" method form). Changed it to a normal link and everything now seems to be working as it should. :)
