close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

duplicate entry

Thread begun 8/18/2011 11:31 am by mycalidesigns | Last modified 8/18/2011 2:53 pm by Jason Byrnes | 2256 views | 3 replies |

mycalidesigns

duplicate entry

please help i have been trying to figure this out for two days now, i have tried all forum suggestions nothing seems to help.

Its basic form that submits a category to database, i am trying to make it were it checks before inserting to see if there is a duplicate.

here is my code:


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_rsCat = "-1";
if (isset($_POST['CategoryName'])) {
$colname_rsCat = (get_magic_quotes_gpc()) ? $_POST['CategoryName'] : addslashes($_POST['CategoryName']);
}
mysql_select_db($database_myCaliDB, $myCaliDB);
$query_rsCat = sprintf("SELECT CategoryName FROM productcategories WHERE CategoryName = %s", GetSQLValueString($colname_rsCat, "text"));
$rsCat = mysql_query($query_rsCat, $myCaliDB) or die(mysql_error());
$row_rsCat = mysql_fetch_assoc($rsCat);
$totalRows_rsCat = mysql_num_rows($rsCat);
?>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$WAFV_Redirect = "optiongroups_Delete.php";
$_SESSION['WAVT_productcategoriesInsertvalidate_626_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateNM($totalRows_rsCat . "",-1,0,"",",.",true,1);

if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"productcategoriesInsertvalidate_626");
}
}
?>
<?php
// WA Application Builder Insert
if ($_SERVER["REQUEST_METHOD"] == "POST") // Trigger
{
$WA_connection = $myCaliDB;
$WA_table = "productcategories";
$WA_sessionName = "WADA_Insert_productcategories";
$WA_redirectURL = "storedashboard.php?CategoryName=".((isset($_POST["CategoryName"]))?$_POST["CategoryName"]:"") ."";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_indexField = "CategoryID";
$WA_fieldNamesStr = "CategoryName";
$WA_fieldValuesStr = "".((isset($_POST["CategoryName"]))?$_POST["CategoryName"]:"") ."";
$WA_columnTypesStr = "',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_myCaliDB;
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/pagewrap_plain.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Insert productcategories</title>
<link href="../css/mycali.css" rel="stylesheet" type="text/css" />
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<link href="../WA_DataAssist/styles/Refined_Pacifica.css" rel="stylesheet" type="text/css" />
<link href="../WA_DataAssist/styles/Arial.css" rel="stylesheet" type="text/css" />
<!-- InstanceEndEditable -->
</head>
<body>
<div class="container">
<div class="topheader"></div>

<div class="globalnav">
<div class="bttn1"><img src="../images/images/longboard-site_04.jpg" width="63" height="52" /><img src="../images/images/longboard-site_05.jpg" width="55" height="52" /></div>
<form id="form1" name="form1" method="post" action="">
<label for="search"></label>
<input name="search" type="text" id="search" size="20" maxlength="50" />
search
</form>
</div>
<div class="navbar"><ul class="nav"><li><img src="../images/images/longboard-site_09.jpg" width="226" height="67" /></li>
<li><img src="../images/images/longboard-site_10.jpg" width="139" height="67" /></li>
<li><img src="../images/images/longboard-site_11.jpg" width="144" height="67" /></li>
<li><img src="../images/images/longboard-site_12.jpg" width="285" height="67" /></li>

</ul>
<div class="clearfloat"></div>
<!-- end .navbar --></div>
<!-- InstanceBeginEditable name="pagewrapper" -->
<div class="pagewrapper">
<div id="WADAPageTitleArea">
<div id="WADAPageTitle"><h2>Insert New Product Category</h2>
<p>Simple insert new category.</p>
</div>
<div><!--<a href="products_Search.php">New Search</a>--></div>
<div><a href="javascript: history.go(-1)">Back</a></div>
</div>
<div class="WADAInsertContainer">
<form action="productcategories_Insert.php" method="post" name="WADAInsertForm" id="WADAInsertForm">
<div class="WADAHeader">Insert Record</div>
<div class="WADAHorizLine"><img src="../WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<table class="WADADataTable" cellpadding="0" cellspacing="0" border="0">
<tr>
<th class="WADADataTableHeader">new Category Name:</th>
<td class="WADADataTableCell"><input type="text" name="CategoryName" id="CategoryName" 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">&nbsp;</td>
<td class="WADADataNavButtonCell" nowrap="nowrap"><input type="image" name="Insert" id="Insert" value="Insert" alt="Insert" src="../WA_DataAssist/images/Pacifica/Refined_insert.gif" /></td>
<td class="WADADataNavButtonCell" nowrap="nowrap"><a href="storedashboard.php" title="Cancel"><img border="0" name="Cancel" id="Cancel" alt="Cancel" src="../WA_DataAssist/images/Pacifica/Refined_cancel.gif" /></a></td>
</tr>
</table>
<input name="WADAInsertRecordID" type="hidden" id="WADAInsertRecordID" value="" />
</div>
</form>
</div>
</div><!--end page wrapper-->

<!-- InstanceEndEditable --><!-- end rightcontent-->
<div class="push"></div>
</div><!--end container-->
<div class="footer">
<p>bottom spacer</p>
<p></p>
</div><!--end footer-->
</body>

<!-- InstanceEnd --></html>
<?php
mysql_free_result($rsCat);

?>

Sign in to reply to this post

Jason ByrnesWebAssist

all the code looks correct, the only thing i can think, is that you have renamed the page, but not changed the forms action:
<form action="productcategories_Insert.php" method="post" name="WADAInsertForm" id="WADAInsertForm">

the forms action is set to post to the productcategories_Insert.php:
action="productcategories_Insert.php"

if you created a back upo pf that file and are adding the modifications to the back up, you would be bypassing them.


try changing the form tag to:
<form action="" method="post" name="WADAInsertForm" id="WADAInsertForm">


if you continue to have problems, please compress the original php page to a zip archive and attach the zip file to your reply rather paste the page code.

Sign in to reply to this post

mycalidesigns

big thanks

thanks for your prompt response, it worked!!!!! i will attach zipfile next time.

quick question, how do i add a error phrase when it checks that it has duplicate category?

Sign in to reply to this post

Jason ByrnesWebAssist

add the error message to the page, then highlight it.

With the error highlighted, go to WebAssist -> Forms -> Validation -> Validation Show If

in the validation show if wizard, select he Number validation from the validation fail list, then click the plus button to add it to the triggers for the error to display.

Sign in to reply to this post

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...