Re: not gettingg desired results... is my programming logic run amuck...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ok... Here we go.... 

> On Tuesday 28 December 2004 23:43, GH wrote:
> 
> 
> > During the code... it gets to the following point...
> >
> > [snip]
> > #############################################
> > # Check if report report is present or not  #
> > #############################################
> > if(!mysql_num_rows($dba['results']['attendance_report'])){
> >  #report is not present
> >  return 0;
> > }
> > else {
> >  #report is present
> >  return 1;
> >  #gets here
> > }
> > [/snip]
> >
> > it gets to the return 1 section....
> 
> Just to be sure, how are you determining that your code does indeed goes to
> the 'else' branch and return 1? Because if it does indeed return 1 then:
> 
>   echo isAttendanceReport(1); // should display 1
> 
> For debugging something like this I would put in echo statements (or
> trigger_error()) all over the place to indicate which part of the code is
> being executed.
> 
> > however the calling statement just does not seem to work....
> 
> If isAttendanceReport() did indeed return 1 then the if-clause in
> displayMenu() would be obviously be true and would obviously execute (unless
> you have uncovered a bug in PHP). So the most likely explanation is that
> isAttendanceReport() is NOT returning 1.
> 
> > using SID = 1, mysql_num_rows($dba['results']['attendance_report'])
> > evaluates to 8
> >
> > Dunno if that helps....
> 
> How does $dba['results']['attendance_report'] get assigned? What variables
> does it rely on? What variables are present/not present in the case that
> succeeds/fails?

$dba['query']['attendance_report'] = "Select A.AttID, P.Part_ID,
P.LastName, P.FirstName, A.Present FROM Attendance A, Participants P,
Sessions S Where P.Part_ID = A.Participant  AND  S.SessionID =
A.Session AND A.Session = ".$sd . ' ORDER BY P.LastName ASC';

# attendance_report --> Query is written above.
$dba['results']['attendance_report'] =
mysql_query($dba['query']['attendance_report']) or
die('$dba[\'query\'][\'attendance_report\']: '.mysql_error());

> 
> > > Isolate the problem, just run isAttendanceReport() on its own and plugin
> > > various values to see what comes back.
> >
> > How can I do that... I have tried but how do you see what the output
> > is? I have tried just echo  ing it, print_r, var_dump ...
> 
> By not running unnecessary code. In this case you seemed to have determined
> that isAttendanceReport() is not returning what you think it should be
> returning. Hence running displayMenu() to test for the return value of
> isAttendanceReport() is unnecessary, particularly when the execution of
> displayMenu() is itself subject to a switch construct. So cut through the
> crap and just run isAttendanceReport() direct as in:
> 
>   echo isAttendanceReport(SOME_VALUE_FOR_SID);
> 
> If you still don't get any joy then dig deeper. What isAttendanceReport()
> returns is solely dependent on:
> 
>   mysql_num_rows($dba['results']['attendance_report'])

This return 8 for some the SID value of 1


> 
> As I have hinted above you have to find out what code is setting
> $dba['results']['attendance_report'], what factors (variables) will affect
> that code, and even try running that bit of code direct instead of going
> through isAttendanceReport() (which itself is adding another layer of
> unnecessary complexity).

Most of isAttendanceReport() comes directly from the code of
AttendanceReport() --> the function that fulls the report... the only
thing that it does does diffrently is is check to see if the data is
there instead of displaying the data.

When I was doing the DEBUGGING I had put " echo 'got here(line
number)'; " statements during the code and it displayed going through
out the isAttendanceReport().

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux