close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Duplicate Database Entries

Thread began 12/01/2010 8:24 am by msbannister373603 | Last modified 12/03/2010 11:32 am by msbannister373603 | 5989 views | 9 replies

msbannister373603

Duplicate Database Entries

I need help getting the server validation to work. I'm simply trying stop my database from accepting duplicate entries. The checked entry is not a unique key and the dreamweaver check username behavior doesn't work. Please advise. I'm using the server validation with Validation toolkit and I've followed the advice from the posts on this forum to no avail. The code is below:

<?php require_once('../../Connections/basketball.php'); ?>
<?php require_once("../../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once("../../WA_ValidationToolkit/WAVT_Scripts_PHP.php"); ?>
<?php require_once("../../WA_ValidationToolkit/WAVT_ValidatedForm_PHP.php"); ?>

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}

$colname_girls_players = "-1";
if (isset($_GET['name'])) {
$colname_girls_players = (get_magic_quotes_gpc()) ? $_GET['name'] : addslashes($_GET['name']);
}
mysql_select_db($database_basketball, $basketball);
$query_girls_players = sprintf("SELECT * FROM girls_players WHERE name = %s", GetSQLValueString($colname_girls_players, "text"));
$girls_players = mysql_query($query_girls_players, $basketball) or die(mysql_error());
$row_girls_players = mysql_fetch_assoc($girls_players);
$totalRows_girls_players = mysql_num_rows($girls_players);?>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$WAFV_Redirect = "../validation/player_exists.html";
$_SESSION['WAVT_girlsplayersInsert_626_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateNM($totalrows_girls_players['name'] . "",-1,0,"",",.",false,1);

if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"girlsplayersInsert_626");
}
}
?>
<?php
// WA Application Builder Insert
if ($_SERVER["REQUEST_METHOD"] == "POST") // Trigger
{
$WA_connection = $basketball;
$WA_table = "girls_players";
$WA_sessionName = "girls_players_players_id";
$WA_redirectURL = "girls_players_sResults.php";
$WA_keepQueryString = false;
$WA_indexField = "players_id";
$WA_fieldNamesStr = "name";
$WA_fieldValuesStr = "".((isset($_POST["name"]))?$_POST["name"]:"") ."";
$WA_columnTypesStr = "',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_basketball;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/home_admin.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SCHS Basketball Database</title>
<script type="text/javascript">
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
</script>
<script type="text/javascript" src="../../CSSMenuWriter/cssmw/menu.js"></script><!--[if lte IE 6]>
<style type="text/css" media="all">
@import url("CSSMenuWriter/cssmw/menu_ie.css");
</style>

<![endif]-->
<link href="../../css/admin.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="wrapper">
<div id="header">
</div>
<div id="sidebar"> </div>
<div id="main_content">
<div id="nav"><a href="../admin_home.php"><img src="../../WA_DataAssist/images/Nautica/Traditional_home.gif" name="home" width="83" height="27" border="0" id="home" /></a><img src="../../WA_DataAssist/images/Nautica/Traditional_Logout.gif" width="83" height="27" border="0" /></div>

<!-- InstanceBeginEditable name="Title" -->
<div id="page_title">
<h1>Add Girls Players</h1>
</div>
<!-- InstanceEndEditable -->
<div id="data"><!-- InstanceBeginEditable name="main_content" -->

<div class="WADAInsertContainer">
<form method="POST" name="WADAInsertForm" id="WADAInsertForm">
<div class="move_left">Insert Girls Player:</div>
<div class="WADAHorizLine"><img src="../../WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<table border="0" cellpadding="0" cellspacing="10" class="WADADataTable" id="tb_insert">
<tr>
<th class="WADADataTableHeader">Player's Name</th>
<td class="WADADataTableCell"><input type="text" name="name" id="name" value="" size="32" /></td>
</tr>
</table>
<div class="WADAHorizLine"><img src="../../WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<div class="WADAButtonRow">
<table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="WADADataNavButtonCell" nowrap="nowrap"><input type="image" name="Insert" id="Insert" value="Insert" alt="Insert" src="../../WA_DataAssist/images/Nautica/Traditional_insert.gif" /></td>
<td class="WADADataNavButtonCell" nowrap="nowrap"><a href="../admin_home.php" title="Cancel"><img border="0" name="Cancel" id="Cancel" alt="Cancel" src="../../WA_DataAssist/images/Nautica/Traditional_cancel.gif" /></a></td>
</tr>
</table>
<input name="WADAInsertRecordID" type="hidden" id="WADAInsertRecordID" value="" />
</div>
</form>
</div>
<!-- InstanceEndEditable --></div>
</div><!--end main_content-->
<div id="footer">
<p>2010 &copy; One Twelve Sports | contact us | about us | privacy rights | terms and conditions | site by Mike Bannister Media</p>
</div>
</div>
<!--end wrapper-->
<div id="apDiv1"></div>
</body>
<!-- InstanceEnd --></html>
<?php
mysql_free_result($girls_players);
?>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...