rubing Posted February 3, 2008 Share Posted February 3, 2008 Hey all, I am running a script which selects mysql records based on a user input string. And then parses them out as new records based on a delimeter. This works fine. However, I also want to eliminate all the records from my table that contain the original input string. Seems like a simple DELETE command, but just won't work any way I try it! It doesn't produce an error, but doesn't delete any records either. what gives!? Please HELP!!!!!!!! <?php include '../lib/config.inc'; include '../lib/opendb.inc'; $split_this = $_POST['split_this']; //the user input string to be split up $delimit=$_POST['delim']; //the delimeter $query = "SELECT * FROM MusicEvents WHERE Band = '$split_this'"; //THIS WORKS FINE $sql = mysql_query($query); while($row = mysql_fetch_array($sql, MYSQL_ASSOC)) { $musicians = explode($delimit,$row['Band']); foreach($musicians as $musician) { $musician=trim($musician," "); //trims space and comma from front and back $venue = $row['Venue']; $dateme = $row['Date']; echo $venue; echo $musician; $sorez = "explosion"; $querynew = "INSERT INTO MusicEvents (Source, Band, Venue, Date) VALUES ('$sorez', '$musician','$venue','$dateme')"; //Also Works!!! $sqlnew = mysql_query($querynew); } } $final_query ="SELECT * FROM MusicEvents WHERE Band = '$split_this'"; mysql_query($final_query); //This query does nothing!! ARGHHHH!!!!! echo "done"; mysql_close($conn); ?> Link to comment https://forums.phpfreaks.com/topic/89200-solved-mysql-delete-command-does-nothing/ Share on other sites More sharing options...
mattal999 Posted February 3, 2008 Share Posted February 3, 2008 $final_query ="SELECT * FROM MusicEvents WHERE Band = '$split_this'"; mysql_query($final_query); //This query does nothing!! ARGHHHH!!!!! that just reselects it... Link to comment https://forums.phpfreaks.com/topic/89200-solved-mysql-delete-command-does-nothing/#findComment-456743 Share on other sites More sharing options...
trq Posted February 3, 2008 Share Posted February 3, 2008 The query in your code which you say does nothing is a SELECT query. Link to comment https://forums.phpfreaks.com/topic/89200-solved-mysql-delete-command-does-nothing/#findComment-456744 Share on other sites More sharing options...
rubing Posted February 3, 2008 Author Share Posted February 3, 2008 That was a mistake in copying and pasting into this forum!!! OOOppps!!! My code reads: $final_query ="DELETE * FROM MusicEvents WHERE Band = '$split_this'"; mysql_query($final_query); It should work perfectly b/c the initial queries based on the same variable all have no problem!!! Unfortunately no records are being deleted. Link to comment https://forums.phpfreaks.com/topic/89200-solved-mysql-delete-command-does-nothing/#findComment-456866 Share on other sites More sharing options...
trq Posted February 3, 2008 Share Posted February 3, 2008 $final_query ="DELETE FROM MusicEvents WHERE Band = '$split_this'"; Link to comment https://forums.phpfreaks.com/topic/89200-solved-mysql-delete-command-does-nothing/#findComment-456877 Share on other sites More sharing options...
rubing Posted February 3, 2008 Author Share Posted February 3, 2008 Thorpe, thank-you so much!!! I owe you a beer if you're ever in alabama. That problem drove me near crazy!!!! I still don't understand why DELETE * doesn't work??? Link to comment https://forums.phpfreaks.com/topic/89200-solved-mysql-delete-command-does-nothing/#findComment-456927 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.