Jump to content

[SOLVED] having trouble deleting from mysql


contra10

Recommended Posts

I'm trying to delete an event in a query the problem is i can't find the problem as the form goes through and shows no errors yet the event is still present

 

<?php
	$uiu = mysql_real_escape_string($_POST['uiu']);
	if (isset($_POST['delete'])) { 

		$querydelete  = "DELETE FROM `events` WHERE `eid`= '$uiu'";
$resultdel = mysql_query($querydelete) or die(mysql_error());;

		$querydeletes  = "DELETE FROM `events_subscribers` WHERE `eventid`= '$uiu'";
$resultdels = mysql_query($querydeletes) or die(mysql_error());;

   mysql_connect("localhost", "root", "") or die(mysql_error()); 
    mysql_select_db("userimages") or die(mysql_error());

$querydeleteimg  = "DELETE FROM `tbl_eventimages` WHERE `eventid`= '$uiu'";
$resultdelimg = mysql_query($querydeleteimg) or die(mysql_error());;
	?>
		Your event has been delete
		<?php
		}else{
			?>
YOU ARE ABOUT TO DELETE YOUR EVENT <?php echo "$evname"; ?>
<?php echo "<input type='hidden' name='uiu' value='$id'>"?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="submit" value="Delete" name="delete">
</form>
<?php
		}
		?>

 

Link to comment
Share on other sites

The value for your submit button is different to that in the line below. In the submit button you have value="Delete"

 

so this line should be

 

if (isset($_POST['Delete'])) {

 

Hope this works for you

 

 

No, it coincides with the name, how he had it is correct.

Link to comment
Share on other sites

i didn't explain it well...im trying to conect to two different databases by deleting one that contains information and the other to delete the image

 

Note the connections to registration and userimage

<?php

if(is_numeric($_GET['ev'])){

$id = $_GET['ev'];
}

    mysql_connect("localhost", "root", "") or die(mysql_error()); 
    mysql_select_db("registration") or die(mysql_error());

$query  = "SELECT * FROM `events` WHERE `eid`= '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))
{
$eidnum = "{$row['eid']}";
    $evname = "{$row['evname']}"; 
}
?>
	<?php
	$uiu = mysql_real_escape_string($_POST['uiu']);
	if (isset($_POST['delete'])) { 

		$querydelete  = "DELETE FROM `events` WHERE `eid`= '$uiu'";
$resultdel = mysql_query($querydelete) or die(mysql_error());

		$querydeletes  = "DELETE FROM `events_subscribers` WHERE `eventid`= '$uiu'";
$resultdels = mysql_query($querydeletes) or die(mysql_error());

   mysql_connect("localhost", "root", "") or die(mysql_error()); 
    mysql_select_db("userimages") or die(mysql_error());


$querydeleteimg  = "DELETE FROM `tbl_eventimages` WHERE `eventid`= '$uiu'";
$resultdelimg = mysql_query($querydeleteimg) or die(mysql_error());
	?>

Link to comment
Share on other sites

k my $id is set from this

 

<?php

if(is_numeric($_GET['ev'])){

$id = $_GET['ev'];
}

    mysql_connect("localhost", "root", "") or die(mysql_error()); 
    mysql_select_db("registration") or die(mysql_error());

$query  = "SELECT * FROM `events` WHERE `eid`= '$id'";
$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))
{
$eidnum = "{$row['eid']}";
    $evname = "{$row['evname']}"; 
}
?>

 

i checked it and the variable does show

Link to comment
Share on other sites

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.