Jump to content


Photo

I can INSERT INTO but not DELETE??


  • Please log in to reply
3 replies to this topic

#1 steff_dk

steff_dk
  • Members
  • PipPip
  • Member
  • 17 posts
  • LocationSilkeborg, Denmark

Posted 30 October 2006 - 09:41 PM

What's wrong with the below code?
If $R1 is V1 it inserts the value alright - if $R1 is V2 nothing happens...

I have tried changing the mysql_query() to print() and I can see the SQL code looks fine  ???

if($R1=='V1'){
//set the database connection variables
$dbHost = "localhost";
$dbUser = "thedomain_com";
$dbPass = "pass";
$dbDatabase = "thedomain_com";
//connect to the database
$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");
mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");
mysql_query("INSERT INTO tilmeldinger(medlemID, arrangementID) VALUES($medlemID, $arrangementID)", $db);
//Go back to admin page
header( "Location: viewarr.php?ID=$arrangementID" );
}

elseif($R1=='V2'){
//set the database connection variables
$dbHost = "localhost";
$dbUser = "thedomain_com";
$dbPass = "pass";
$dbDatabase = "thedomain_com";
//connect to the database
$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");
mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");
mysql_query("DELETE * FROM tilmeldinger WHERE medlemID = $medlemID AND arrangementID = $arrangementID", $db);
//Go back to admin page
header( "Location: viewarr.php?ID=$arrangementID" );
}


#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 30 October 2006 - 09:44 PM

Do not use * in a DELETE query, just --> DELETE FROM table WHERE something = '$something' etc

#3 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 30 October 2006 - 09:45 PM

remove the * from your query
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#4 steff_dk

steff_dk
  • Members
  • PipPip
  • Member
  • 17 posts
  • LocationSilkeborg, Denmark

Posted 30 October 2006 - 10:01 PM

Excellent! It works now!  ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users