how to 'debug' newby lost

Discussion of testing theory and practice, including methodologies (such as TDD, BDD, DDD, Agile, XP) and software - anything to do with testing goes here. (Formerly "The Testing Side of Development")

Moderator: General Moderators

Post Reply
daffy
Forum Newbie
Posts: 7
Joined: Wed Aug 19, 2009 7:29 am

how to 'debug' newby lost

Post by daffy »

Having come from a tightly structured compiled language like Pascal which throws exceptions, I am a bit lost.

I find that if I have a PHP function functionA() which calls another function functionB() and there is a syntax error of any sort in functionB I get an error in function A saying 'call to undefined functionB() at line 13' or similar.
The 'line 13' points to the line of the call to B in functionA but tells me nothing about where the error in functionB is.
Is this standard and is there any way around it, apart from putting masses of echo "xxx"; around the place?
Is it unusual to call one function from another in PHP ?
I am trying to learn !
--
Dave
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: how to 'debug' newby lost

Post by jackpf »

That error means that functionB doesn't exist. What's your code?
daffy
Forum Newbie
Posts: 7
Joined: Wed Aug 19, 2009 7:29 am

Re: how to 'debug' newby lost

Post by daffy »

Hi Jackpf, nice place Ipswitch.

Thanks for your interest and potential help, I started to put the code in here then it is so long-winded and sphagetti-like that it would be difficult to follow.

But I will do it if it will help

The code is in a Joomla system so it has its own queer conventions and way of writing a database query (for very good reason).

Essentially there is a function 'getProd' which looks up a product id, name, and type from the database.
The function getProd is called from a function formOpts. It is written as a function because I want to use it in several places.

If the correct stuff has been put into the database it all works fine, but if the database query returns no result because there is nothing there the error message says that 'getProd' cannot be found.

This is like saying you cant find the 'Rose and Crown' just because the 'Rose and Crown' has run out of beer. I would like to echo a sensible message if the appropriate entry has not been put into the database.

I would much rather be writing OO code which I am reasonably used to , but I cannot find where in Joomla to put my class definitions and I am in a race against time.
--
Dave
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: how to 'debug' newby lost

Post by jackpf »

Oooh you're using Joomla...

Yeah, I have no idea about Joomla. I've never used it myself.

I'd guess that if the function does exist, but you're getting this error message, then it's something Joomla is outputting. Try looking through the source of the function returning the error, or searching all Joomla files for your error message.

Also, try this:

Code: Select all

var_dump(function_exists('your_func_name'))
And Ipswich, yeah, I guess it isn't bad lol. Cheers.

Good luck,
Jack.
daffy
Forum Newbie
Posts: 7
Joined: Wed Aug 19, 2009 7:29 am

Re: how to 'debug' newby lost

Post by daffy »

OK thanks Jack, If there is a Rose & Crown in Ipswich I would buy you a beer is they had any..
--
Dave
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: how to 'debug' newby lost

Post by jackpf »

Lol, I'm only 16...wouldn't want you getting in trouble.

Let me know if you get it working.

All the best,
Jack.
User avatar
juma929
Forum Commoner
Posts: 72
Joined: Wed Jun 17, 2009 9:41 am

Re: how to 'debug' newby lost

Post by juma929 »

Hello,

Your 16 8O. Nothing wrong with that but you know when you picture somebody in your mind when you talk online, I pictured you much older than 16 lol.

:P
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: how to 'debug' newby lost

Post by jackpf »

Lol, I imagine most people probably do. :)
Post Reply