contra10 Posted February 26, 2009 Share Posted February 26, 2009 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 } ?> Quote Link to comment https://forums.phpfreaks.com/topic/147061-solved-having-trouble-deleting-from-mysql/ Share on other sites More sharing options...
premiso Posted February 26, 2009 Share Posted February 26, 2009 Your mysql connection gets started below 2 of the delete queries. Move that above them and it should work. Quote Link to comment https://forums.phpfreaks.com/topic/147061-solved-having-trouble-deleting-from-mysql/#findComment-772038 Share on other sites More sharing options...
MadTechie Posted February 26, 2009 Share Posted February 26, 2009 move the connection up also whats with all the ;; 's Quote Link to comment https://forums.phpfreaks.com/topic/147061-solved-having-trouble-deleting-from-mysql/#findComment-772039 Share on other sites More sharing options...
pcw Posted February 26, 2009 Share Posted February 26, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/147061-solved-having-trouble-deleting-from-mysql/#findComment-772040 Share on other sites More sharing options...
premiso Posted February 26, 2009 Share Posted February 26, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/147061-solved-having-trouble-deleting-from-mysql/#findComment-772048 Share on other sites More sharing options...
contra10 Posted February 27, 2009 Author Share Posted February 27, 2009 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()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/147061-solved-having-trouble-deleting-from-mysql/#findComment-772384 Share on other sites More sharing options...
MadTechie Posted February 27, 2009 Share Posted February 27, 2009 change <?php echo "<input type='hidden' name='uiu' value='$id'>"?> to <?php echo "<input type='text' name='uiu' value='$id'>"?> to check the $id is correct as i don't see where your setting it! Quote Link to comment https://forums.phpfreaks.com/topic/147061-solved-having-trouble-deleting-from-mysql/#findComment-772458 Share on other sites More sharing options...
contra10 Posted March 1, 2009 Author Share Posted March 1, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/147061-solved-having-trouble-deleting-from-mysql/#findComment-773547 Share on other sites More sharing options...
contra10 Posted March 1, 2009 Author Share Posted March 1, 2009 could connecting to two different db cause trouble Quote Link to comment https://forums.phpfreaks.com/topic/147061-solved-having-trouble-deleting-from-mysql/#findComment-773553 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.