Jump to content




Recent Status Updates

  • Photo
      15 Nov
    duzamucha

    Hi, I am final year Interior Design Student from University of Huddersfield. I am currently working on my final major project which is going to be linked to coding. I was hoping that you could help me with my research. I have prepared a short survey, it would be a massive help if you could fill it in for me. It takes less than 2 minutes to complete, I promise. Here is the link: https://www.surveymonkey.com/s/73XLJKK Thank you so much in advance!

View All Updates

Developed by TechBiz Xccelerator
Photo
- - - - -

need fresh eyes.


  • Please log in to reply
2 replies to this topic

#1 zeroradius

zeroradius

    Speaks fluent binary

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1,081 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

    YOL9

  • Moderator
  • 3,942 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

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#3 zeroradius

zeroradius

    Speaks fluent binary

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1,081 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




Powered by binpress