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
		}
		?>

 

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.

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());
	?>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.