Jump to content

[SOLVED] mysql DELETE command does nothing...


rubing

Recommended Posts

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

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.

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.