Jump to content

Recommended Posts

I am having trouble getting this to work when ever I try to have the following script run:

[code]if($_GET['act'] == "delete_recent_match"){

$id = $_GET["edit_recent_match2"];
    $query = "DELETE FROM recent_match WHERE id='$id'";
mysql_query($query) or die (mysql_error());

if(!$query){
echo '<font id=UserNameRed />There has been an error deleting the data. Please contact the webmaster.';
}else{
echo '<font id=UserNameRed />The data was deleted successfully.';
}
}[/code]

I get this in the browser address:

[quote]http://mysite.com/delete_recent_match_proc.php?delete_recent_match=1&submit=submit[/quote]

I know its because this page is on the same page as the file from where in trying to execute it but why does it go to the "&submit=submit" line?? Im not sure of what I should do to correct this.
Link to comment
https://forums.phpfreaks.com/topic/13912-help-with-mysql-delte-from-table-idid/
Share on other sites

[quote author=cameeob2003 link=topic=99736.msg392877#msg392877 date=1152233839]
I am having trouble getting this to work when ever I try to have the following script run:

[code]
if($_GET['act'] == "delete_recent_match"){

$id = $_GET["edit_recent_match2"];
    $query = "DELETE FROM recent_match WHERE id='$id'";
mysql_query($query) or die (mysql_error());

if(!$query){
echo '<font id=UserNameRed />There has been an error deleting the data. Please contact the webmaster.';
}else{
echo '<font id=UserNameRed />The data was deleted successfully.';
}
}[/code]

I get this in the browser address:

[quote]http://mysite.com/delete_recent_match_proc.php?delete_recent_match=1&submit=submit[/quote]

I know its because this page is on the same page as the file from where in trying to execute it but why does it go to the "&submit=submit" line?? Im not sure of what I should do to correct this.
[/quote]

"if($_GET['act'] == "delete_recent_match")"  you need to make the address http://mysite.com/delete_recent_match_proc.php?delete_recent_match=1&submit=submit&act=delete_recent_match... also i would make the code like......
[code]
if($_GET['act'] == "delete_recent_match"){

$id = $_GET["edit_recent_match2"];
    $query = mysql_query("DELETE FROM recent_match WHERE id='$id'") or die (mysql_error());

if(!$query){
echo '<font id=UserNameRed />There has been an error deleting the data. Please contact the webmaster.';
}else{
echo '<font id=UserNameRed />The data was deleted successfully.';
}
}
[/code]
then you would go to that page in the format of http://yoursite.com/page.php?act=delete_recent_match&edit_recent_match2=<this would be the $id variable in your script>
Would I set it in that way by the following:

[code] if($_GET['act'] == "edit_matches&delete_recent_match"){

$id = $_GET["edit_recent_match2"];
    $query = mysql_query("DELETE FROM recent_match WHERE id='$id'") or die (mysql_error());

if(!$query){
echo '<font id=UserNameRed />There has been an error deleting the data. Please contact the webmaster.';
}else{
echo '<font id=UserNameRed />The data was deleted successfully.';
}
}[/code]
i would use a code like
[code]if($_GET['act'] == "del"){

$id = $_GET["id"];
    $query = mysql_query("DELETE FROM recent_match WHERE id='$id'") or die (mysql_error());

if(!$query){
echo '<font id=UserNameRed />There has been an error deleting the data. Please contact the webmaster.';
}else{
echo '<font id=UserNameRed />The data was deleted successfully.';
}
}[/code] and call to it with something like http://site.com/page.php?act=del&id=<what you want $id to be>
I am not sure why this wont delete the actuall posting from the mysql database I have reviewed several websites and different forums to find the answer to my knowldge it is as it should be. The only problem is when I go to delete the post it says deleted and will not delete the post. Here is the code im using to do so:

[code]<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>n2p - Nothing to Prove</title>
<link rel="stylesheet" href="n2p.css" type="text/css" />
</head>

<body>
<?php
include("db.php");
if($_GET['act'] == "delete"){
//include database files

$id = $_GET['delete_news'];
$sql = mysql_query("DELETE FROM news WHERE id='$id'") or die (mysql_error());

if(!sql){
echo "Could not delete news post.";
}else{
echo "News post deleted.";
}
}
?>
<form method="post" name="delete_old_news" action="?act=delete">
<table>
<tr>
<td>
<select name="news_posts">
<?php
// Delete Highlight Match

$sql = "SELECT * FROM `news` order by `id`";
$result  = mysql_query($sql) or die(mysql_error());
while ($text = mysql_Fetch_array($result)) {
$id = $text['id'];
$title = $text['title'];
$ndate = $text['date'];

echo '<option name="delete_news" value="'.$id.'">'. $title .' '. $ndate .'</option><br/>';}

?>
</select>
</td>
</tr>
<td><input name="submit" type="submit" value="submit" /></td></tr>
</table>
</form>
</body>
</html>
[/code]

If someone could explain why this isnt working to me that would be great im realy wanting to learn the reson why.
What about the scripts he put:
[code]<?php
include("db.php");
if($_GET['act'] == "delete"){
//include database files

$id = $_GET['delete_news'];
$sql = mysql_query("DELETE FROM news WHERE id='$id'") or die (mysql_error());

if(!sql){
echo "Could not delete news post.";
}else{
echo "News post deleted.";
}
}
?>[/code]

He could access that code by going to the link. Am I right ?
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.