I get the message query was empty any time i try to delete a record from a table. The same script performs update and indert without problems. Below is the code
Language: php (GeSHi-highlighted)
<?php
//create short variable names
//$gad1=$_POST['gad1'];
$tramount=$_POST['tramount'];
$credebcard=$_POST['credebcard'];
$cash=$_POST['cash'];
$cheque=$_POST['cheque'];
$deptopcard=$_POST['deptopcard'];
$standord=$_POST['standord'];
$bico=$_POST['bico'];
$curency=$_POST['curency'];
$transtype=$_POST['transtype'];
$actiontype = $_POST['actiontype'];
//addslashes before store
//$gad1=addslashes($gad1);
$tramount=addslashes($tramount);
$credebcard=addslashes($credebcard);
$cash=addslashes($cash);
$cheque=addslashes($cheque);
$deptopcard=addslashes($deptopcard);
$standord=addslashes($standord);
$bico=addslashes($bico);
$curency=addslashes($curency);
$transtype=addslashes($transtype);
// start session which may be needed later
// start it now because it must go before headers
session_start();
$host = 'localhost';
$user = '******';
$password = '*****';
$dbName = '******';
// connect and select the database
$conn = mysql_connect($host, $user, $password) or die(mysql_error());
$db = mysql_select_db($dbName, $conn) or die(mysql_error());
if ($actiontype == "addRec")
// insert new entry into database
$sql = "insert into chargestable (tramount, credebcard, cash, cheque, deptopcard, standord, bico, curency, transtype) values ('$tramount', '$credebcard', '$cash', '$cheque', '$deptopcard', '$standord', '$bico', '$curency', '$transtype')";
elseif ($actiontype == "deleteRec")
$sql = "DELETE FROM chargestable WHERE tramount = '$tramount'";
elseif ($actiontype == "amendRec")
$sql = "UPDATE chargestable SET credebcard = '$credebcard', cash = '$cash', cheque = '$cheque', deptopcard = '$deptopcard', standord = '$standord', bico = '$bico' WHERE tramount = '$tramount'";
$result = mysql_query($sql, $conn) or die(mysql_error());
header('Location: charges.php');
?>
thnx