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
Share on other sites

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.