Jump to content




Recent Status Updates

  • Photo
      18 Aug
    KodeKool

    When faced with a wall of errors and no hope to fix them, remember the following "Programs always do what you tell them to, and seldom what you want them to, but eventually you'll run out of things that can go wrong and it'll just work. and that's the secret to good programming."

    Show comments (2)
View All Updates

Developed by Kemal Taskin
Photo
- - - - -

need fresh eyes.


  • Please log in to reply
2 replies to this topic

#1 zeroradius

zeroradius

    Speaks fluent binary

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1,080 posts

Posted 30 December 2011 - 06:25 AM

I have this fatal error:

Call to a member function customQuery() on a non-object


Here is the code it is referring to ($data in the foreach loop)

<select name="doctor"> <?php $query = "Select id,name From doctors"; foreach($data->customQuery($query) as $doctor) { echo "<option value='".$doctor[0]."'>" . $doctor[1] . "</option>"; } ?> </select>


Here is the controller that creates the $data object

public function appointmentForm() { $data = new dbHandler("A problem has occured. Please notify an admin." ); include("views/newAppointment.php"); }


and here is the switch clause that creates the controller

case appointment: include_once("views/newAppointment.php"); $app = new appointmentController(); echo $app->appointmentForm(); break;



Just for the sake of clarity. here is another page that works the same exact way that is working (same order)!

the part that is not working in the other code but is working here

<select name="doctor"> <?php $query = "Select id,name From doctors"; foreach($data->customQuery($query) as $doctor) { echo "<option value='".$doctor[0]."'>" . $doctor[1] . "</option>"; } ?> </select>


controller

public function surgeryForm(){$data = new dbHandler("A problem has occured. Please notify an admin." ); include_once("views/newSurgery.php"); }


and the switch

case surgery: include_once("controllers/surgeryController.php"); $sur = new surgeryController(); echo $sur->surgeryForm(); break;


(I took out all the white space. the php tags on here destroyed the structure, sorry)

With the exception of file and variable names these two should be identical! I can't find were i screwed up
:crying:
  • 0
Posted Image

#2 Alexander

Alexander

    I do have 9 lives, you know.

  • Moderator
  • 3,872 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 30 December 2011 - 03:02 PM

I bet that if you look at $data it will be null or false. How are your functions changing $data? Why not $this->data? Why does your first code not use include_once when the second one does?
  • 0
Be sure to check out the new site additions - brought to you by your friendly CODECALL staff-person.
If a suggested code/method fails, informing us is less important than telling us why or what errors had occurred.

#3 zeroradius

zeroradius

    Speaks fluent binary

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1,080 posts

Posted 31 December 2011 - 06:50 AM

well i don't know much about OOP just what i taught myself (have a book on the way) but i thought $this->$var was for variables that could be used for all methods in a class. I need $data to only be usable inside of the method because $data is used in almost every method in my controller class (like declaring $i = 1, you use it in the method and then throw it away)(is that not acurate?).

Originally it all used include_once. I don't remember why i changed it but i need to change it back.

The way this is set up is: Front controller (switch statement) creates an instance of the controller and calls the appointmentForm() method in the controller class and the controller creates an instance of the dbHandler class and calls the custom query method tieing the returned data into a drop down list on the View which is also gotten by the controller

I have a couple days off now so I can rest and then look at it. It's probably something simple i'm over looking.


  • 0
Posted Image