Jump to content

[SOLVED] mysql DELETE command does nothing...


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.

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.