steff_dk Posted October 30, 2006 Share Posted October 30, 2006 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 pageheader( "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 pageheader( "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 More sharing options...
alpine Posted October 30, 2006 Share Posted October 30, 2006 Do not use * in a DELETE query, just --> DELETE FROM table WHERE something = '$something' etc Link to comment https://forums.phpfreaks.com/topic/25630-i-can-insert-into-but-not-delete/#findComment-116976 Share on other sites More sharing options...
.josh Posted October 30, 2006 Share Posted October 30, 2006 remove the * from your query Link to comment https://forums.phpfreaks.com/topic/25630-i-can-insert-into-but-not-delete/#findComment-116977 Share on other sites More sharing options...
steff_dk Posted October 30, 2006 Author Share Posted October 30, 2006 Excellent! It works now! ;) Link to comment https://forums.phpfreaks.com/topic/25630-i-can-insert-into-but-not-delete/#findComment-116982 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.