[SOLVED] Multiple Delete functions
Posted: Fri Apr 15, 2005 5:40 pm
If I pass a URL parameter to this, the delete function works perfectly:
If I try to add another delete function (see below) then the script stops working in that it doesn’t delete but neither do I get an error.
Can anyone advise or show me where I’m going wrong? Can I not have more than one delete function on one page?
Thanks very much.
Brian
Code: Select all
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
if ((isset($_GET['ensembleID'])) && ($_GET['ensembleID'] != "")) {
$deleteSQL = sprintf("DELETE FROM conpositions_ensemble WHERE ensembleID=%s",
GetSQLValueString($_GET['ensembleID'], "int"));
mysql_select_db($database_johnston, $johnston);
$Result1 = mysql_query($deleteSQL, $johnston) or die(mysql_error());
}
?>Can anyone advise or show me where I’m going wrong? Can I not have more than one delete function on one page?
Thanks very much.
Brian
Code: Select all
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
if ((isset($_GET['electro_ID'])) && ($_GET['electro_ID'] != "")) {
$deleteSQL = sprintf("DELETE FROM compositions_electro WHERE electro_ID=%s",
GetSQLValueString($_GET['electro_ID'], "int"));
}
elseif ((isset($_GET['ensembleID'])) && ($_GET['ensembleID'] != "")) {
$deleteSQL = sprintf("DELETE FROM conpositions_ensemble WHERE ensembleID=%s",
GetSQLValueString($_GET['ensembleID'], "int"));
}
elseif ((isset($_GET['programme_ID'])) && ($_GET['programme_ID'] != "")) {
$deleteSQL = sprintf("DELETE FROM programme_notes WHERE programme_ID=%s",
GetSQLValueString($_GET['programme_ID'], "int"));
mysql_select_db($database_johnston, $johnston);
$Result1 = mysql_query($deleteSQL, $johnston) or die(mysql_error());
}