Errors When Attempting To Insert Into JEvent Database with PHP

cyberspyder 24 Jul, 2019
I'm trying to insert an event into a JEvent database but on submit the following errors seem to occur. I'm not quite sure what part of the code could be making this happen.

Object of class stdClass could not be converted to string in /mnt/stor13-wc2-dfw1/561654/2024034/www.efortsmith.com/web/content/libraries/cegcore2/admin/extensions/chronofc/functions/php/php_output.php(6) : eval()'d code on line 145
count(): Parameter must be an array or an object that implements Countable in /mnt/stor13-wc2-dfw1/561654/2024034/www.efortsmith.com/web/content/plugins/jevents/jevfiles/jevfiles.php on line 1218

Here is a link to the form - http://www.efortsmith.com.php72-2.phx1-2.websitetestlink.com/add-event
And here is the php code in question and a backup of the form in question.
$db = JFactory::getDBo();

$select = 'SELECT * FROM #__jevents_vevdetail WHERE evdet_id= 1';
$db->setQuery($select);
$entry_id = $db->loadResult();

$currenttime = date('Y-m-d H:i:s');
$start = strtotime(str_replace('/', '-', $this->data("publish_up2", "default value")) . ' ' . $this->data("start_time", "default value"));
$end = strtotime(str_replace('/', '-', $this->data("publish_down2", "default value")) . ' ' . $this->data("end_time", "default value"));
echo($this->data("publish_down2", "default value") . '<p></p>' . $this->data("end_time", "default value") . '<p></p>');

$object = new stdClass();
$object->evdet_id = $this->data("aid", "default value");
$object->rawdata = '';
$object->dtstart = $this->data("start", "default value");
$object->dtstartraw = '';
$object->duration = '0';
$object->durationraw = '';
$object->dtend = $this->data("end", "default value");
$object->dtendraw = '';
$object->dtstamp = '';
$object->class = '';
$object->categories = '';
$object->color = '';
$object->description = $this->data("description", "default value");
$object->geolon = '0';
$object->geolat = '0';
$object->location = $this->data("location_name", "default value");
$object->priority = '0';
$object->status = '';
$object->summary = $this->data("description", "default value");
$object->contact = $this->data("name", "default value");
$object->organizer =$this->data("name", "default value");
$object->url = '';
$object->extra_info = '';
$object->created = '';
$object->sequence = '0';
$object->state = '1';
$object->modified = $currenttime;
$object->multiday = ceil(($start - $end)/86400.0);
$object->hits = '0';
$object->noendtime = '0';
$object->loc_id = '0';


$object2 = new stdClass();
$object2->id = '1';
$object2->evdet_id = $this->data("aid", "default value");
$object2->user_id = '0';
$object2->rp_id = '0';
$object2->name = 'Address';
$object2->value = $this->data("jform_Address", "default value");
$object2->language = '*';
$object3 = new stdClass();
$object3->id = '2';
$object3->evdet_id = $this->data("aid", "default value");
$object3->user_id = '0';
$object3->rp_id = '0';
$object3->name = 'Public_Phone';
$object3->value = $this->data("jform_Public_Phone", "default value");
$object4 = new stdClass();
$object4->id = '3';
$object4->evdet_id = $this->data("aid", "default value");
$object4->user_id = '0';
$object4->rp_id = '0';
$object4->name = 'City';
$object4->value = $this->data("jform_City", "default value");
$object4->language = '*';
$object3->language = '*';
$object5 = new stdClass();
$object5->id = '4';
$object5->evdet_id = $this->data("aid", "default value");
$object5->user_id = '0';
$object5->rp_id = '0';
$object5->name = 'Website';
$object5->value = $this->data("jform_Website", "default value");
$object5->language = '*';
$object6 = new stdClass();
$object6->id = '5';
$object6->evdet_id = $this->data("aid", "default value");
$object6->user_id = '0';
$object6->rp_id = '0';
$object6->name = 'State';
$object6->value = $this->data("jform_State_loc", "default value");
$object6->language = '*';
$object7 = new stdClass();
$object7->id = '6';
$object7->evdet_id = $this->data("aid", "default value");
$object7->user_id = '0';
$object7->rp_id = '0';
$object7->name = 'AdmissionCost';
$object7->value = $this->data("jform_AdmissionCost", "default value");
$object7->language = '*';


$object8 = new stdClass();
$object8->ev_id = $this->data("aid", "default value");
$object8->icsid = '1';
$object8->catid = '8';
$object8->uid = '';
$object8->refreshed = '0000-00-00 00:00:00';
$object8->created = $currenttime;
$object8->created_by = '314';
$object8->created_by_alias = '';
$object8->modified_by = '314';
$object8->rawdata = '';
$object8->recurrence_id = '';
$object8->detail_id = $this->data("aid", "default value");
$object8->state = '1';
$object8->lockevent = '0';
$object8->author_notified = '0';
$object8->access = '1';
$object8->tzid = '';


$object9 = new stdClass();
$object9->rp_id = $this->data("aid", "default value");
$object9->eventid = $this->data("aid", "default value");
$object9->eventdetail_id = $this->data("aid", "default value");
$object9->duplicatecheck = '';
$object9->startrepeat = $this->data("publish_up2", "default value") . ' ' . $this->data("start_time", "default value");
$object9->endrepeat = $this->data("publish_down2", "default value") . ' ' . $this->data("end_time", "default value");


$object10 = new stdClass();
$object10->rr_id = $this->data("aid", "default value");
$object10->eventid = $this->data("aid", "default value");
$object10->freq = 'none';
$object10->until = '0';
$object10->untilraw = '';
$object10->count = '1';
$object10->rinterval = '1';
$object10->bysecond = '';
$object10->byminute = '';
$object10->byhour = '';
$object10->byday = '';
$object10->bymonthday = '';
$object10->byyearday = '';
$object10->byweekno = '';
$object10->bymonth = '';
$object10->bysetpos = '';
$object10->wkst = '';
$object10->irregulardates = '[]';

$db->setQuery("INSERT INTO #__jevents_vevdetail VALUES(" . $object . ")");
$db->setQuery("INSERT INTO #__jev_customfields VALUES(" . $object2 . ")");
$db->setQuery("INSERT INTO #__jev_customfields VALUES(" . $object3 . ")");
$db->setQuery("INSERT INTO #__jev_customfields VALUES(" . $object4 . ")");
$db->setQuery("INSERT INTO #__jev_customfields VALUES(" . $object5 . ")");
$db->setQuery("INSERT INTO #__jev_customfields VALUES(" . $object6 . ")");
$db->setQuery("INSERT INTO #__jev_customfields VALUES(" . $object7 . ")");
$db->setQuery("INSERT INTO #__jevents_vevent VALUES(" . $object8 . ")");
$db->setQuery("INSERT INTO #__jevents_repetition VALUES(" . $object9 . ")");
$db->setQuery("INSERT INTO #__jevents_rrule VALUES(" . $object10 . ")");

​[file=http://www.efortsmith.com.php72-2.phx1-2.websitetestlink.com/add-event]ADD EVENTS_24_Jul_2019_09_26_36.cf6bak[/file]
healyhatman 24 Jul, 2019
................. Why are you doing all of that into the first place anyway? What's wrong with just using the Save Data action? Also you shouldn't literally type "default value" as the second parameter for the $this->data() function, you should either not use it at all or put the value you want to be returned by default if the field is null.
This topic is locked and no more replies can be posted.