Re: Is it a bug of CakePHP?

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

 



> > Pham Huu Le Quoc Phuc a écrit :
> > > I catch an error, could you tell me if you have some ideas?
> > >
> > > Error message: Undefined index: start_date in
> > > c:\Inetpub\wwwroot\Cake\app\controllers\dsptrainings_controller.php on
> line
> > > 33
> > >

PHP is telling you that what you are trying to access doesn't exist. 
This is is a matter of you trying to access something that doesn't
exist.

So the question is, what does $data look like?  My suggestion is to
print_r($data) to see.  Perhaps findBySql() doesn't return the results
as an associative array?  Or since you're sending a query for only one
record, it doesn't send a 2-dimensional array back? Maybe your start
date can be accessed simply by $data['start_date']?  I don't know, I
don't use CakePHP.

Again, print your $data variable to the screen to find out what it contains.

Consider this to be a powerful tool in your bag of debugging tricks. 
I print variables to the screen all the time to find out what's wrong.
 In fact, I'll do it in a two step process:

print_r($my_variable);
die("<hr>filename.php:line_num");

The first line prints the variable I'm after to the screen.  The
second line kills the script, but outputs the text I send it first. 
So it draws a horizontal rule across the page, and then prints out the
file name and line number that the script was killed at.

So if I'm tracing a particularly elusive bug, I can place these two
lines in various places across my app, and walk through it step by
step.  The important part is knowing the filename and location of your
debugging marks, so that you can clean them up easily.

HTH,
John W

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