stockton Posted March 29, 2007 Share Posted March 29, 2007 I use the following to call Ajax :- <input type="button" value="Issue" Onclick="sendRequest('.$IssueTickets.",".$Event.',1)"> and sendRequest looks like:- function sendRequest(Mode, Event, CardNumber) { // Call PHP script for requests if (Mode == 2) // ClientData { http.open('get', 'T3.php?EventID='+Event+'&MemberNum='+CardNumber); http.onreadystatechange = handleClientDataResponse; } else if (Mode == 3) // IssueTickets { var KaartNommer = TicketIssue.CardNumber.value; var SlotsValue = document.getElementById("SlotsValue").innerHTML; var SlotsTurnover = document.getElementById("SlotsTurnover").innerHTML; var TablesValue = document.getElementById("TablesValue").innerHTML; var TablesTurnover = document.getElementById("TablesTurnover").innerHTML; var BonusValue = document.getElementById("BonusValue").innerHTML; http.open('get', 'T4.php?EventID='+Event+'&MemberNum='+KaartNommer+'&SlotsValue='+SlotsValue+'&SlotsTurnover='+SlotsTurnover+'&TablesValue='+TablesValue+'&TablesTurnover='+TablesTurnover); http.onreadystatechange = handleIssueTicketsResponse; } http.send(null); } T4.php looks like:- <?php // // T4.php called from T2.php to Issue tickets // Retrieve data from T2 screen and insert into TicketIssued table // require_once('includes/configuration.php'); // database connect script & the rest. DBConnect(); // Connect to Events database $Datum = date("Y-m-d H:i:s"); /* 2006-03-17 23:22:32 */ $Event = strip_tags($_GET['EventID']); $MemberNum = strip_tags($_GET['MemberNum']); $SlotsValue = strip_tags($_GET['SlotsValue']); $ValueSlots = sprintf("%d",$SlotsValue); $SlotsTurnover = strip_tags($_GET['SlotsTurnover']); $TablesValue = strip_tags($_GET['TablesValue']); $ValueTables = sprintf("%d",$TablesValue); $TablesTurnover = strip_tags($_GET['TablesTurnover']); if ($ValueSlots > 0) { $EarnType = "Slots"; $SQL = sprintf("INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID) VALUES ('%s', '%d', '%s', '%s', '%d', '%d', '%d')", $Datum, $Event, $MemberNum, $EarnType, $SlotsValue, $SlotsTurnover, $_SESSION['UID']); $rs = mssql_query($SQL, $link); if (!$rs) echo get_sql_error($SQL, $link, $sError, $bDebug); } if ($ValueTables > 0) { $EarnType = "Tables"; $SQL = sprintf("INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID) VALUES ('%s', '%d', '%s', '%s', '%d', '%d', '%d')", $Datum, $Event, $MemberNum, $EarnType, $TablesValue, $TablesTurnover, $_SESSION['UID']); $rs = mssql_query($SQL, $link); if (!$rs) echo get_sql_error($SQL, $link, $sError, $bDebug); } DBDisConnect(); // Disconnect from Events database ?> The problem is that I end up with two identical records in the TicketsIssued table. Note that these records are identical, not one for "Slots" and one for "Tables". Suggestions on what I have done wrong would be gratefully received. Quote Link to comment Share on other sites More sharing options...
stockton Posted April 9, 2007 Author Share Posted April 9, 2007 I used :- ALTER TABLE table-name ADD CONSTRAINT NoDuplicates UNIQUE (Date,MemberNumber) After having read of:- http://www.thescripts.com/forum/thread156807.html and the problem has gone away Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.