MyBB Community Forums

Full Version: [F] submitting a calendar event - bad timestamp type in SQL query [C-Chris]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ok, so I tried inserting the first event into my calendar:
MyBB has experienced an internal SQL error and cannot continue.
SQL Error:
22P02 - ERROR: invalid input syntax for integer: "" 
Query:
INSERT INTO mybb_events (cid,uid,name,description,visible,private,dateline,starttime,endtime,timezone,ignoretimezone,usingtime,repeats) VALUES ('1','1','Klasówka z Mickiewicza','Klasówka z jęzka polskiego z życia i twórczości Adama Mickiewicza.','1','0','1228158352','1228867200','0','','0','0','N;')

I've checked the timestamp column type. It's integer. And digging into the code, I found it treated it as a string. The solution which worked for me is down here.

Suggested change to inc/datahandlers/event.php:
464c464
<                       'timezone' => $db->escape_string($event['timezone']),
---
>                       'timezone' => intval($event['timezone']),
Probably shouldn't occur under normal circumstances, since the select box should always have a number, but I agree that we shouldn't just assume a number is given.

Should use floatval instead of intval, since a decimal could be given, but then the column type for 'timezone' needs to be changed (note, setting a timezone which isn't an integer now, will stuff things up).
Although integer != float. Would spit out an error if a comma was to be seen.
Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.

With regards,
MyBB Group