CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge -> Programming

 Combine fields for validation / validate multi-field index

Print topic Send  topic

Author Message
Drcox
Posted: 02/23/2006, 1:22 PM

I am trying to prevent the following error...
MySQL Error: 1062 (Duplicate entry 'me@mymail.org-20-Lane' for key 2)
Session halted.

MySQL database as a unique index for the 3 following fields...
email, streetno, & streetname.

The generated code for validating each field separately is provided below. I need to combine the 3 into one single statement.

I am using codecharge 2.0.7 PHP 4.0 w/ templates.

Does anyone know how to do this? Thanks!!!

if(strlen($fldemail) )
{
$iCount = 0;

if($sAction == "insert")
$iCount = get_db_value("SELECT count(*) FROM members WHERE email=" . tosql($fldemail, "Text"));
else if($sAction == "update")
$iCount = get_db_value("SELECT count(*) FROM members WHERE email=" . tosql($fldemail, "Text") . " and not(" . $sWhere . ")");
if($iCount > 0)
$sNewtempErr .= "The value in field E-mail* is already in database.<br>";
}

if(strlen($fldstreetname) )
{
$iCount = 0;

if($sAction == "insert")
$iCount = get_db_value("SELECT count(*) FROM members WHERE streetname=" . tosql($fldstreetname, "Text"));
else if($sAction == "update")
$iCount = get_db_value("SELECT count(*) FROM members WHERE streetname=" . tosql($fldstreetname, "Text") . " and not(" . $sWhere . ")");
if($iCount > 0)
$sNewtempErr .= "The value in field streetname is already in database.<br>";
}

if(strlen($fldstreetno) && is_numeric($fldstreetno))
{
$iCount = 0;

if($sAction == "insert")
$iCount = get_db_value("SELECT count(*) FROM members WHERE streetno=" . tosql($fldstreetno, "Number"));
else if($sAction == "update")
$iCount = get_db_value("SELECT count(*) FROM members WHERE streetno=" . tosql($fldstreetno, "Number") . " and not(" . $sWhere . ")");
if($iCount > 0)
$sNewtempErr .= "The value in field streetno is already in database.<br>";


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.