Jump to content

I can INSERT INTO but not DELETE??


steff_dk

Recommended Posts

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  ???

[code]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" );
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/25630-i-can-insert-into-but-not-delete/
Share on other sites

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.