CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Default a date field

Print topic Send  topic

Author Message
ckroon

Posts: 869
Posted: 07/17/2007, 3:49 PM

Hi all. Sort of a complicated problem here but I am sure one you geniuses out there can figure it out quick enough.

I have a form that teachers must fill out with correct dates. IF the dates are wrong, the school doesnt get any money, which means they hate me.

There is a date field (date1) that will display the date the student had their enrollment approved. I have a textbox which displays that date in a record form.. no problem.

What I need to do is this: if that enrollment approved date is before the first day of school, then it needs to default to the first day of school. The first day of school can be found in the Dates table (first_day_date) I hope that makes sense.

Any help is greatly appreciated.

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
datadoit.com
Posted: 07/17/2007, 4:34 PM

Kinda sorta like this:

date1 BeforeShow event:

global $DBConnectionNameDB;

$enrollment_date = $Component->GetValue()
$first_day_of_school = CCDLookUp("first_day_date", "Dates", "WHERE
whatever", $DBConnectionNameDB);

if (strtotime($enrollment_date) < strtotime($first_day_of_school)) {
$Component->SetValue($first_day_of_school);
}
ckroon

Posts: 869
Posted: 07/17/2007, 5:33 PM

hanks datadoit. I took your code and I am getting this error:

Parse error: parse error, unexpected T_VARIABLE in c:\inetpub\wwwroot\Cavatesttest\isma\ismaeditfall_events.php on line 24

Here is what I got:

//begin code

global $DBcavamaster;

$ISMA_date = $Component->GetValue()
$first_day_of_school = CCDLookUp("date_fallisma1", "zdates", "WHERE ", $DBcavamaster); [not in code: this is line 24]

if (strtotime($ISMA_date) < strtotime($first_day_of_school)) {
$ISMA_date->SetValue($first_day_of_school);
}

//End code

Details: cavamaster is db name
ISMA_date is the label name of the student's start date
zdates is the table and date_fallisma1 is hte field where the first day of school date is located.

I know I messed something up somewhere, just can't figure out where.

Thanks!
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
datadoit.com
Posted: 07/17/2007, 6:06 PM

The "WHERE" part of the CCDLookup() function is whatever WHERE parameter
you would use to get the record you need.

Ex: "id=1"

The CCDLookup is similar to using in MySQL:

SELECT data_fallisma1 FROM zdates WHERE whatever
ckroon

Posts: 869
Posted: 07/17/2007, 6:45 PM

GRRRRRR

cant...get...it...to...work!

global $DBcavamaster;

$ISMA_date = $Component->GetValue()
$first_day_of_school = CCDLookUp("date_fallisma1", "zdates", "WHERE ID=1", $DBcavamaster);

if (strtotime($ISMA_date) < strtotime($first_day_of_school)) {
$ISMA_date->SetValue($first_day_of_school);
}

//endcode

something wrong with my syntax in the where clause?


_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
datadoit.com
Posted: 07/18/2007, 5:48 AM

Remove the "WHERE" word from your CCDLookUp() function.

CCDLookUp("date_fallisma1", "zdates", "id='1'", $DBcavamaster);

See
http://docs.codecharge.com/studio31/html/Components/Fun.../CCDLookUp.html

This is assuming your table 'zdates' looks something like this:

id date_fallisma1
--- --------------
1 2007-08-20

ckroon

Posts: 869
Posted: 07/18/2007, 7:06 AM

I am STILL getting the error:

//begin code

global $DBcavamaster;

$ISMA_date = $Component->GetValue()
$first_day_of_school = CCDLookUp("date_fallisma1", "zdates", "ID='1'", $DBcavamaster);

if (strtotime($ISMA_date) < strtotime($first_day_of_school)) {
$ISMA_date->SetValue($first_day_of_school);
}
//end code


Error: Parse error: parse error, unexpected T_VARIABLE in..... on line 24.000
(line 24 is the third line of code above.)

Parse errors I can usually find, but not this one.

Just a clarification for my learning purposes.. $first_day_of_school is something I created correct, it does not need to be a component in the record, correct?



_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
Wkempees
Posted: 07/18/2007, 7:20 AM

try putting a dot comma ; after the line starting with $ISMA


like this
$ISMA_date = $Component->GetValue();


that should do it
also
suggestion,
reverse the use of double and single quotes like this for now on:

$first_day_of_school = CCDLookUp('date_fallisma1', 'zdates', 'ID="1"',
$DBcavamaster);

but as ID is probably a tinyinteger you only need this

$first_day_of_school = CCDLookUp('date_fallisma1', 'zdates', 'ID=1',
$DBcavamaster);

Walter
Wkempees
Posted: 07/18/2007, 7:22 AM

a classic example of getting entangled in problems not having to do with
the problem at hand.
You deeply study the line od code you want to make work not seeing the
problem in the line before, which in fact isn't the line before because
the separator is missing.

"Tell it to the cat"

Walter
ckroon

Posts: 869
Posted: 07/18/2007, 7:30 AM

Well.. I get a new error :)

Fatal error: Call to a member function on a non-object in c:\inetpub\wwwroot\Cavatesttest\Common.php on line 475

Line 475 in common.php is $db->query($sql);

?? the database is called 'cavamaster'.
Strange
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
Wkempees
Posted: 07/18/2007, 7:34 AM

please post here the currently used code.
Also state in which event.
Use copy and paste, so we are surely looking at the code at hand.
ckroon

Posts: 869
Posted: 07/18/2007, 7:39 AM

On Before Show event on label ISMA_date

//begin code
global $DBcavamaster;

$ISMA_date = $Component->GetValue();
$first_day_of_school = CCDLookUp('date_fallisma1', 'zdates', 'ID="1"', $DBcavamaster);

if (strtotime($ISMA_date) < strtotime($first_day_of_school)) {
$ISMA_date->SetValue($first_day_of_school);
}
//end code

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
datadoit.com
Posted: 07/18/2007, 7:56 AM

I noticed that the name of your label is ISMA_date. You're also
attempting to set a variable using the same name $ISMA_date. I'm not
certain if this is a problem or not, but not a good idea, at least for
clarity purposes.

Change the name of your variable to something other than the label name.
Wkempees
Posted: 07/18/2007, 8:02 AM

At first glance it looks ok to me.
So check your connection name $DBcavamaster to be ok.
Are you sure that is typed ok, no $DBCavamaster or so.

ckroon

Posts: 869
Posted: 07/18/2007, 8:03 AM

//begin code

global $DBcavamaster;

$ISMA_date1 = $Component->GetValue();
$first_day_of_school = CCDLookUp('date_fallisma1', 'zdates', 'ID="1"', $DBcavamaster);

if (strtotime($ISMA_date1) < strtotime($first_day_of_school)) {
$ISMA_date1->SetValue($first_day_of_school);
}
//end code

Ok. Renamed it to ISMA_date1 for clarity. Still getting the same error as aobve.. Fatal error: Call to a member function on a non-object in .... common.php line 475.

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
ckroon

Posts: 869
Posted: 07/18/2007, 8:09 AM

Walter: checked it, it is cavamaster (small letters)

So strange.

the error line in Common.php is $db->query($sql);

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
Wkempees
Posted: 07/18/2007, 8:36 AM

From test:
If connection name is wrongly type $DBCavamaster for instance
then the message will read
Fatal error: Call to a member function query() on a non-object in
.........\Common.php on line xxx

So your connection name is most likely ok spelled.

I cannot find anything other wrong.
My suggestion would be to republish the whole project.
Do the following:
Make a Backup firts.
then delete all .php files except(!) the ones ending in _events.php
both in your projects working directory and in the target publishing
directory
Then restart CCS, open your project and publish (F8)

and let us know how thins evolve.
(I am signing off now till later)
minlo

Posts: 3
Posted: 07/18/2007, 8:52 AM

i always use double qoute in CCDLOOKUP
and use $Componet instead in before show event to set value

//begin code

$first_day_of_school = CCDLookUp("date_fallisma1", "zdates", "ID='1'", $DBcavamaster);

$Componet->SetValue($first_day_of_school);
//end code

View profile  Send private message
wkempees
Posted: 07/18/2007, 3:58 PM

@minlo
Besides the typo ($Componet <=> $Component) you are right when in the Before
Show of that component.
For instance in the Before Show event of ISMA_date1
  
//begin code  
  
global $DBcavamaster;  
  
if (strtotime($Component->GetValue()) <   
strtotime(CCDLookUp('date_fallisma1', 'zdates', 'ID="1"', $DBcavamaster)))  
    {  
       $Component->SetValue($first_day_of_school);  
     }  
  
//end code  
  

Should be perfectly ok.

@ckroon
try this one:

  
//begin code  
  
$db = new clsDBcavamaster();  
  
if (strtotime($Component->GetValue()) <   
strtotime(CCDLookUp('date_fallisma1', 'zdates', 'ID="1"', $db)))  
    {  
       $Component->SetValue($first_day_of_school);  
     }  
  
$db->close();  
  
//end code  
  

It does the same as before, difference being to use a different
databaseconect.

Walter

ckroon

Posts: 869
Posted: 07/18/2007, 5:49 PM

Hey all. Built it again from scratch,same errors.

Walter in your previous code I don't see where $first_day_of_school was defined..?

I pasted it and got a fatal error.

FYI: The textbox that this before show code is on is called "fall_start" and it's default value is a CCGetFromGet.

Not sure if that makes a difference or not.

_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
Wkempees
Posted: 07/19/2007, 4:41 AM

In my last post, the one starting with @minlo

The code is highly compacted so we do not need the temporary field
$first_day_of_school

I am on the road today so it is hard to keep up with you.
One more time, from your final build, post the current code.
I will have a close look upon return.
Or e-mail me.

We will solve this!
Meanwhile this could give a good hint as to what is wrong
using your last code, change it to the following and see if any data is
displayed on your page if it publishes errorfree:

  
//begin code  
  
global $DBcavamaster;  
  
echo 'data: '. CCDLookUp('date_fallisma1', 'zdates', 'ID="1"',  
$DBcavamaster);  
  
/*  
$ISMA_date1 = $Component->GetValue();  
$first_day_of_school = CCDLookUp('date_fallisma1', 'zdates', 'ID="1"',  
$DBcavamaster);  
  
if (strtotime($ISMA_date1) < strtotime($first_day_of_school)) {  
        $ISMA_date1->SetValue($first_day_of_school);  
        }  
*/  
  
//end code  
ckroon

Posts: 869
Posted: 07/19/2007, 5:10 AM

Still nothing working.
I will email it to you Walter, this thread is getting too long.
Will post the solution here when we get it.
Thanks all!
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
ckroon

Posts: 869
Posted: 07/20/2007, 12:00 PM

Doh!

Connection name... NOT database name. I put database name everywhere.

Thanks folks!

$DBConnection1... not cavamaster.


_________________
Walter Kempees...you are dearly missed.
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.

MS Access to Web

Convert MS Access to Web.
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.