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
how to 'debug' newby lost
Moderator: General Moderators
Re: how to 'debug' newby lost
That error means that functionB doesn't exist. What's your code?
Re: how to 'debug' newby lost
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
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
Re: how to 'debug' newby lost
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:
And Ipswich, yeah, I guess it isn't bad lol. Cheers.
Good luck,
Jack.
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'))Good luck,
Jack.
Re: how to 'debug' newby lost
OK thanks Jack, If there is a Rose & Crown in Ipswich I would buy you a beer is they had any..
--
Dave
--
Dave
Re: how to 'debug' newby lost
Lol, I'm only 16...wouldn't want you getting in trouble.
Let me know if you get it working.
All the best,
Jack.
Let me know if you get it working.
All the best,
Jack.
Re: how to 'debug' newby lost
Hello,
Your 16
. 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.

Your 16
Re: how to 'debug' newby lost
Lol, I imagine most people probably do. :)