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 Studio -> PHP

 Lookup of value on MYSQL db [Resolved]

Print topic Send  topic

Author Message
acedrummond


Posts: 90
Posted: 05/02/2011, 8:52 AM

I'm trying to look up a field on my database to make sure it is not already there before allowing the user to continue.

Here is my code:

global $DBConnection1;
$Page = CCGetParentPage($sender);

$ccs_result = CCDLookUp('participant_eMail', 'jinet_members', "where participant_eMail = ".$Container->participant_eMail->GetValue(), $Page->Connections["Connection1"]);
$ccs_result = strval($ccs_result);
CCSetSession("on_file", $ccs_result);
$Container->Errors->addError("Test".ccgetsession('on_file'));

I get no data in the session variable even though the test data is present!

Any clues please?
.

_________________
Ace Drummond
View profile  Send private message
datadoit
Posted: 05/02/2011, 9:55 AM

First, you're not flushed yet (flush(), ob_flush()). That may or may
not matter. Second, ccgetsession() is not CCGetSession().

To test for the value before flushing the page, just refer to the
$ccs_result value.
acedrummond


Posts: 90
Posted: 05/02/2011, 10:50 AM

Quote datadoit:
First, you're not flushed yet (flush(), ob_flush()). That may or may
not matter. Second, ccgetsession() is not CCGetSession().

To test for the value before flushing the page, just refer to the
$ccs_result value.

I appreciate your input, but still nothing! Revised code below:

This did not solve my problem:

FYI ccgetsession and ccsetsession work as well as those with CCSet.. and CCGet so that is not a factor.

Also tried flush() and ob_flush() with no effect.

There is something I'm missing here but don't know what it is?

$Page = CCGetParentPage($sender);

$ccs_result = CCDLookUp('participant_eMail', 'jinet_members', "where participant_eMail = ".$Container->participant_eMail->GetValue(), $Page->Connections["Connection1"]);
$ccs_result = strval($ccs_result);

ccsetsession("test","xxx");

$Container->Errors->addError("Test ".$ccs_result." ".ccgetsession("test") );
_________________
Ace Drummond
View profile  Send private message
datadoit
Posted: 05/02/2011, 11:35 AM

Instead of putting your 'test' into an error control, just simply echo
to the screen.

echo "The Result: " . $ccs_result; exit;

Also it's important to know where you're attempting to put this code.
Page BeforeShow? Record BeforeShow? Field BeforeShow? OnValidate?
etc., since you may be in the wrong place at the wrong time when
attempting to assign a value to an error control. We're flying in the
dark without this level of detail from you.

I highly recommend that you follow the naming conventions of CodeCharge
when referring to functions and classes (camel-cased), but to each his
own. It will matter if you're on a case-sensitive system such as Linux,
and doing any sort of script manipulation, CLI search, etc.
acedrummond


Posts: 90
Posted: 05/02/2011, 11:50 AM

Quote datadoit:
Instead of putting your 'test' into an error control, just simply echo
to the screen.

echo "The Result: " . $ccs_result; exit;

Also it's important to know where you're attempting to put this code.
Page BeforeShow? Record BeforeShow? Field BeforeShow? OnValidate?
etc., since you may be in the wrong place at the wrong time when
attempting to assign a value to an error control. We're flying in the
dark without this level of detail from you.

I highly recommend that you follow the naming conventions of CodeCharge
when referring to functions and classes (camel-cased), but to each his
own. It will matter if you're on a case-sensitive system such as Linux,
and doing any sort of script manipulation, CLI search, etc.

Again thanks:

I'm working within On Validate - what I'm trying to do is when input is submitted check to see that this eMail (it is not a key, but it is defined as an index (not unique)) is already on file. I'm using the error display just to see what I am capturing and is always working with on validate. I originally saved to session variable to eliminate the possibility of the variable not being available...

I'm Mysql 5.5.8 php 5.3.5 apache 2.2.17 (a WAMP install unaltered other than for proper date display)

_________________
Ace Drummond
View profile  Send private message
datadoit
Posted: 05/02/2011, 12:30 PM

echo "The Result: " . $ccs_result; exit;

What did you see?

http://docs.codecharge.com/studio40/html/ProgrammingTec...Output.html?toc
acedrummond


Posts: 90
Posted: 05/02/2011, 1:52 PM

Quote datadoit:
echo "The Result: " . $ccs_result; exit;

What did you see?

http://docs.codecharge.com/studio40/html/ProgrammingTec...Output.html?toc

The result is with no data!
_________________
Ace Drummond
View profile  Send private message
datadoit
Posted: 05/02/2011, 1:56 PM

Okay, so that contradicts your original statement...

On 5/2/2011 11:52 AM, acedrummond wrote:
> I get no data in the session variable even thosugh the test data is present!

So now check your lookup statement to make sure it's correct. Again,
back to the echo command, before doing any sort of lookup, make sure you
have a value for the key you're looking for:

echo "The Value: " . $Container->participant_eMail->GetValue(); exit;
acedrummond


Posts: 90
Posted: 05/02/2011, 2:04 PM

I've done that and the value is good and the value is in the db.

I agree that something has to be wrong with the query, but I don't see it yet!

There is only one record in the db and I tried changing the field to lookup and hard coding the value I'm searching for and did not find that record - it just makes no sense so far!

I also tried copying an sql query and got the same result.

If I do a query in myphpadmin it finds things just fine, I took the code and worked that into my statement and still no result.
I appreciate your following up, but this one is a head scratcher!




_________________
Ace Drummond
View profile  Send private message
datadoit
Posted: 05/02/2011, 3:32 PM

Don't use the existing page connection. Create a new one.

$db = new clsDBConnection1();
do your lookup using $db
$db->close();
acedrummond


Posts: 90
Posted: 05/02/2011, 6:50 PM

Quote datadoit:
Don't use the existing page connection. Create a new one.

$db = new clsDBConnection1();
do your lookup using $db
$db->close();

Thanks, but still nada!

I just sent this to support ( Ido subscribe to annual support) for them to look at and will advise what they have to say.

When I know more will advise!
_________________
Ace Drummond
View profile  Send private message
karen

Posts: 99
Posted: 05/07/2011, 4:24 AM

Hi Ace,

I noticed that you have the word "where" in your where condition of CCDLookUp which shouldn't be there. So should look like this.

ccs_result = CCDLookUp('participant_eMail', 'jinet_members', "participant_eMail = ".$Container->participant_eMail->GetValue(), $Page->Connections["Connection1"]);

Also, you could try using double quotes for all the parameters.

Hope that helps.

Cheers,
Karen
View profile  Send private message
acedrummond


Posts: 90
Posted: 05/07/2011, 9:59 AM

Quote karen:
Hi Ace,

I noticed that you have the word "where" in your where condition of CCDLookUp which shouldn't be there. So should look like this.

ccs_result = CCDLookUp('participant_eMail', 'jinet_members', "participant_eMail = ".$Container->participant_eMail->GetValue(), $Page->Connections["Connection1"]);

Also, you could try using double quotes for all the parameters.

Hope that helps.

Cheers,
Karen

I tried your suggestion w/same problem persisting!
_________________
Ace Drummond
View profile  Send private message
Waspman

Posts: 948
Posted: 05/08/2011, 5:17 AM

apart from the obvious unique setting?

I do this in the on validate event (along with all the other stuff)

$db = new clsDBConnection1;
$dupe_email = CCDLookUp("COUNT(*)","tb_users","Email=".$db->ToSQL($Component->email->Value,ccsText),$db);
$db->close();

// Check that the email is unique
if ($dupe_email) {
$Component->Errors->addError("Email address already in use");
}
_________________
http://www.waspmedia.co.uk
View profile  Send private message
acedrummond


Posts: 90
Posted: 05/08/2011, 8:48 AM

Thanks to all who tried to help.

The solution I did finally find was located as an example in the documentation under "Lookup Single Field Value in a Database" as the CCDLookup documentation is a bit lacking.

Here is the solution that works for me:

global $DBConnection1;
global $result;

$Page = CCGetParentPage($sender);

$ccs_result = CCDLookUp("participant_eMail", "jinet_participants", "participant_eMail =". $DBConnection1->ToSQL($Container->participant_eMail->GetValue(), ccsText), $DBConnection1 );
if ($ccs_result <> '') { $Container->Errors->addError("eMail Already Registered!"); }

//End DLookup

_________________
Ace Drummond
View profile  Send private message

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.