Jump to content

Archived

This topic is now archived and is closed to further replies.

steff_dk

I can INSERT INTO but not DELETE??

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]

Share this post


Link to post
Share on other sites
Do not use * in a DELETE query, just --> DELETE FROM table WHERE something = '$something' etc

Share this post


Link to post
Share on other sites

×

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.