ikanku15 Posted June 5, 2007 Share Posted June 5, 2007 hi all, im a newby in this php thing. im doing a websites which use the oop php structure. im using php 4.4.8 somehow, i got this problem occur: Fatal error: Call to a member function on a non-object in /var/www/crmctt/someDir/someName.php on line 153 the code will be some thing like this: <?php /* // // IncidentModel.php // this model class stores only business logic // data is stored in the entity class // */ include_once MODELPATH . 'Model.php'; include ENTPATH . 'Incident.php'; include ENTPATH . 'IncidentType.php'; include ENTPATH . 'ServerDomain.php'; include ENTPATH . 'ServerHostName.php'; include ENTPATH . 'ServerIP.php'; include ENTPATH . 'ServerLocation.php'; include ENTPATH . 'FQDN.php'; include ENTPATH . 'DateTime.php'; class IncidentModel extends Model { var $addSuccess; var $incident; var $loc; var $dom; var $host; /* // // Constructor: IncidentModel() // Description: The incident model of the system // Parameter: $request->httpPost = the information posted by the member // */ function IncidentModel($request = NULL, $user = NULL, $dao = NULL) { // super constructor $this->Model($request, $user, $dao); if($this->request->GetHttpPost()) { $this->ProcessRequest(); } } /* // // Method: ProcessRequest() // Description: Process the request // */ function ProcessRequest() { // local variables $fqdn = NULL; $type = NULL; $email = NULL; $startDateTime = NULL; $endDateTime = NULL; // validation // fqdn: after everything gone ok then the fqdn will be available at $this->fqdn $fqdn = $this->GetFQDN( $this->request->httpPost['ABM_location'], $this->request->httpPost['ABM_host'], $this->request->httpPost['ABM_domain'], 'Please make sure the selection of FQDN is correct'); // validate the type of incident if(!$this->ValidateIsBlank($this->request->httpPost['ABM_type'], 'Please select a type of incident.')) { // query database to get the complete information // create type object $type = new IncidentType($this->request->httpPost['ABM_type'], 'some action'); } // time and date // start date time $startDateTime = new DateTime( $this->request->httpPost['ABM_startTimeHour'], $this->request->httpPost['ABM_startTimeMinutes'], 0, $this->request->httpPost['ABM_startDateMonth'], $this->request->httpPost['ABM_startDate'], $this->request->httpPost['ABM_startDateYear']); $this->ValidateDateTime($startDateTime, 'The start time and date information provided is invalid, please re-check.'); // end date time $endDateTime = new DateTime( $this->request->httpPost['ABM_endTimeHour'], $this->request->httpPost['ABM_endTimeMinutes'], 0, $this->request->httpPost['ABM_endDateMonth'], $this->request->httpPost['ABM_endDate'], $this->request->httpPost['ABM_endDateYear']); $this->ValidateDateTime($endDateTime, 'The end time and date information provided is invalid, please re-check.'); $this->ValidateDateRange($startDateTime, $endDateTime, 'The date range provided is invalid, please check the time and date settings.'); // the reason $this->ValidateIsBlank($this->request->httpPost['ABM_reason'], 'Please fill in the reason field'); // the description $this->ValidateIsBlank($this->request->httpPost['ABM_description'], 'Please fill in the description field'); // the email // first, we strip off the spaces if(!$this->ValidateIsBlank($this->request->httpPost['ABM_email'], 'Please enter an email address')) { $email = str_replace(' ', '', $this->request->httpPost['ABM_email']); // then we explode the list $email = explode(',', $email); // next we loop through the array for($i = 0; $i < count($email); $i++) { $this->ValidateEmail($email[$i], 'The email address %email% entered is invalid.'); } } // object instantiation // everything is checked // create the entity with complete/broken information $this->SetIncident(new Incident( $this->user, $fqdn, $type, $startDateTime, $endDateTime, $this->request->httpPost['ABM_reason'], $this->request->httpPost['ABM_description'], $this->request->httpPost['ABM_email'] )); // database access & email triggering // query to the database if everything is okay // check the statusMsg if(!count($this->GetStatusMsg())) { // data access through the data access object $this->dao->ExecuteQuery(sprintf("INSERT INTO `incident`" . " (`fID`, `uID`, `inTypeID`, `inStartDateTime`, `inEndDateTime`, `inReason`, `inDescription`, `inEmail`, `inLastUpdate`)" . " VALUES(%d, %d, %d, %d, %d, '%s', '%s', '%s', %d)", mysql_real_escape_string($this->incident->fqdn->GetFID(), $this->dao->GetDBConn()), mysql_real_escape_string($this->user->GetID(), $this->dao->GetDBConn()), mysql_real_escape_string($this->incident->type->GetTypeID(), $this->dao->GetDBConn()), mysql_real_escape_string($this->incident->startDateTime->GetTimestamp(), $this->dao->GetDBConn()), //someCode.... the line 153 will be: mysql_real_escape_string($this->incident->startDateTime->GetTimestamp(), $this->dao->GetDBConn()), can anyone help me on this? ??? Quote Link to comment https://forums.phpfreaks.com/topic/54212-fatal-error-call-to-a-member-function-on-a-non-object-in/ Share on other sites More sharing options...
btherl Posted June 5, 2007 Share Posted June 5, 2007 That means that something you thought is an object actually isn't one. Try checking each one individually until you find the culprit. You can use var_dump(), and/or is_object(). Put your checks on the line before the line with the error. You'll need to check $this->incident, then $this->incident->startDateTime, and so on. Quote Link to comment https://forums.phpfreaks.com/topic/54212-fatal-error-call-to-a-member-function-on-a-non-object-in/#findComment-268041 Share on other sites More sharing options...
ikanku15 Posted June 5, 2007 Author Share Posted June 5, 2007 hi btherl, thx for ur quick reply. i hv used the var_dump() to check on the error line. this error come out: Parse error: syntax error, unexpected T_STRING in /var/www/someDir/someName.php on line 154 line 154 still refer to the same error line before and i got no idea what is it. Quote Link to comment https://forums.phpfreaks.com/topic/54212-fatal-error-call-to-a-member-function-on-a-non-object-in/#findComment-268139 Share on other sites More sharing options...
emehrkay Posted June 5, 2007 Share Posted June 5, 2007 i dotn know if you can use commas in the mysql_real_escape_string function replace them with periods Quote Link to comment https://forums.phpfreaks.com/topic/54212-fatal-error-call-to-a-member-function-on-a-non-object-in/#findComment-268361 Share on other sites More sharing options...
btherl Posted June 6, 2007 Share Posted June 6, 2007 Can you post the code that gave you the syntax error? Quote Link to comment https://forums.phpfreaks.com/topic/54212-fatal-error-call-to-a-member-function-on-a-non-object-in/#findComment-268906 Share on other sites More sharing options...
ikanku15 Posted June 6, 2007 Author Share Posted June 6, 2007 here is the code that give me the syntax error mysql_real_escape_string($this->incident->startDateTime->GetTimestamp(), $this->dao->GetDBConn()), Quote Link to comment https://forums.phpfreaks.com/topic/54212-fatal-error-call-to-a-member-function-on-a-non-object-in/#findComment-268925 Share on other sites More sharing options...
ikanku15 Posted June 6, 2007 Author Share Posted June 6, 2007 this code is more detail $this->dao->ExecuteQuery(sprintf("INSERT INTO `incident`" . " (`fID`, `uID`, `inTypeID`, `inStartDateTime`, `inEndDateTime`, `inReason`, `inDescription`, `inEmail`, `inLastUpdate`)" . " VALUES(%d, %d, %d, %d, %d, '%s', '%s', '%s', %d)", mysql_real_escape_string($this->incident->fqdn->GetFID(), $this->dao->GetDBConn()), mysql_real_escape_string($this->user->GetID(), $this->dao->GetDBConn()), mysql_real_escape_string($this->incident->type->GetTypeID(), $this->dao->GetDBConn()), var_dump() // <---- i have added this to the code to check mysql_real_escape_string($this->incident->startDateTime->GetTimestamp(), $this->dao->GetDBConn()), // <---- the code line that generate the error mysql_real_escape_string($this->incident->endDateTime->GetTimestamp(), $this->dao->GetDBConn()), mysql_real_escape_string($this->incident->GetReason(), $this->dao->GetDBConn()), mysql_real_escape_string($this->incident->GetDescription(), $this->dao->GetDBConn()), mysql_real_escape_string($this->incident->GetEmail(), $this->dao->GetDBConn()), mysql_real_escape_string(time(), $this->dao->GetDBConn()))); Quote Link to comment https://forums.phpfreaks.com/topic/54212-fatal-error-call-to-a-member-function-on-a-non-object-in/#findComment-268929 Share on other sites More sharing options...
btherl Posted June 6, 2007 Share Posted June 6, 2007 ikanku, remove the var_dump() you added and add this code outside your ExecuteQuery (on the line before): print "\$this->incident looks like this: ";var_dump($this->incident);print "<br>\n"; print "\$this->incident->startDateTime looks like this: ";var_dump($this->incident->startDateTime);print "<br>\n"; $this->dao->ExecuteQuery( ... And see what it outputs. It should tell you exactly which thing is not an object. Then you need to work out why it isn't an object. Quote Link to comment https://forums.phpfreaks.com/topic/54212-fatal-error-call-to-a-member-function-on-a-non-object-in/#findComment-269008 Share on other sites More sharing options...
ikanku15 Posted June 6, 2007 Author Share Posted June 6, 2007 hi btherl, im manage to find some error (lots act.. huhu).. im working on it n i'll let u know the progress. thanks ya!! Quote Link to comment https://forums.phpfreaks.com/topic/54212-fatal-error-call-to-a-member-function-on-a-non-object-in/#findComment-269020 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.