undefined Id in Php and need help to fix

Support and queries relating to all previous versions of ZoneMinder
Locked
mikerobb
Posts: 5
Joined: Sat Aug 29, 2009 12:54 pm

undefined Id in Php and need help to fix

Post by mikerobb »

Does anyone know what I need to change to get this working? Note the "undefined" variable (Id) getting passed around.

From main window:
1) click on any camera's event (I clicked on Hour "3")
- this brings up the listing of events for that filter
2) click on any event Id
- this brings up and plays back the video for that event
3) click on Video

This error is then displayed in the popup window:

An error has occurred and this operation cannot continue.
For full details check your web logs for the code '660259'

This is from the /var/log/http/error_log
[Sat Aug 29 07:55:36 2009] [error] [client 192.168.202.230] SQL-ERROR(62D88F): select Events.Id as Id, MonitorId, Name, Cause, StartTime, date_format( StartTime, '%y/%m/%d %H:%i:%S' ) as StartTimeShort, EndTime, Width, Height, Length, Frames, AlarmFrames, TotScore, AvgScore, MaxScore, Archived, Videoed, Uploaded, Emailed, Messaged, Executed, Notes, min(Frames.FrameId) as MinFrameId, max(Frames.FrameId) as MaxFrameId, min(Frames.Delta) as MinFrameDelta, max(Frames.Delta) as MaxFrameDelta from Events left join Frames on Events.Id = Frames.EventId where Events.Id = undefined group by Frames.EventId limit 1, referer: http://192.168.202.7/zm/?view=event&eid ... c=1&page=1
[Sat Aug 29 07:55:36 2009] [error] [client 192.168.202.230] SQL-ERROR(62D88F): Unknown column 'undefined' in 'where clause', referer: http://192.168.202.7/zm/?view=event&eid ... c=1&page=1
[Sat Aug 29 07:57:02 2009] [error] [client 192.168.202.230] SQL-ERROR(660259): select E.*,M.Name as MonitorName,M.Width,M.Height,M.DefaultRate,M.DefaultScale from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = undefined, referer: http://192.168.202.7/zm/?view=event&eid ... c=1&page=1
[Sat Aug 29 07:57:02 2009] [error] [client 192.168.202.230] SQL-ERROR(660259): Unknown column 'undefined' in 'where clause', referer: http://192.168.202.7/zm/?view=event&eid ... c=1&page=1

This error is generated from the file ajax/event.php
This line:

Code: Select all

               $sql = "select E.*,M.Name as MonitorName,M.DefaultRate,M.DefaultScale from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = ".dbEscape($_REQUEST['id']).monitorLimitSql();
This is a portion of the HTML page which showed the video and the html link Video that I clicked on:

Code: Select all

 
//
// PHP variables to JS
//
var connKey = '638597';
 
var event = {
    Id: 1841,
    Width: 320,
    Height: 240,
    Length: 1.00};
 
var filterQuery = '&filter[terms][0][attr]=Archived&filter[terms][0][op]=%3D&filter[terms][0][val]=0&filter[terms][1][cnj]=and&filter[terms][1][attr]=DateTime&filter[terms][1][op]=%3E%3D&filter[terms][1][val]=-1+hour&filter[terms][2][cnj]=and&filter[terms][2][attr]=MonitorId&filter[terms][2][op]=%3D&filter[terms][2][val]=1';
var sortQuery = '&sort_field=StartTime&sort_asc=1';
 
var scale = 100;
var canEditEvents = true;
var streamTimeout = 3000;
 
var canStreamNative = false;
 
//
// Strings
//
var deleteString = "Delete";
var causeString = "Cause";
I am running ZM 1.23.3 (fresh install from this past week). I am running CentOs 5.3 (fresh install from this past week).

# uname -a
Linux dvr 2.6.18-128.7.1.el5 #1 SMP Mon Aug 24 08:20:55 EDT 2009 i686 i686 i386 GNU/Linux


# mysql --version
mysql Ver 14.12 Distrib 5.0.45, for redhat-linux-gnu (i686) using readline 5.0

[root@dvr ~]# php --version
PHP 5.1.6 (cli) (built: Apr 7 2009 08:00:04)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

[root@dvr ~]# perl --version

This is perl, v5.8.8 built for i386-linux-thread-multi
mikerobb
Posts: 5
Joined: Sat Aug 29, 2009 12:54 pm

Post by mikerobb »

not sure if this is the correct way to fix this, but this "seems" to work okay:

Code: Select all

/* MAR - next line has a problem */
                //$sql = "select E.*,M.Name as MonitorName,M.DefaultRate,M.DefaultScale from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = ".dbEscape($_REQUEST['id']).monitorLimitSql();
                $sql = "select E.*,M.Name as MonitorName,M.DefaultRate,M.DefaultScale from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = ".dbEscape($_REQUEST['eid']).monitorLimitSql();
                if ( !($event = dbFetchOne( $sql )) )

PSWired
Posts: 9
Joined: Tue Jun 29, 2010 2:18 am

Post by PSWired »

Any update to this problem?

I tried the suggested fix but have the same error.

ZM 1.24.2
MySQL 5.0.77-4
CentOS 5
lrrosa
Posts: 1
Joined: Thu Aug 05, 2010 2:17 pm

Post by lrrosa »

I'm having almost the same problem when clicking on "Video" tab of any event, but it only happens with Google Chrome. On Firefox 3.6 and Explorer 8 it works fine.

My error is FEC794:
SQL-ERROR(FEC794): select E.*,M.Name as MonitorName,M.Width,M.Height,M.DefaultRate,M.DefaultScale from Events as E inner join Monitors as M on E.MonitorId = M.Id where E.Id = undefined, referer: http://localhost/zm/index.php?view=even ... c=1&page=1

SQL-ERROR(FEC794): Unknown column 'undefined' in 'where clause', referer: http://localhost/zm/index.php?view=even ... c=1&page=1
-------------

I'm using Ubuntu 10.4, MySql 5.1.41, ZM 1.24.2 (all installed with apt-get).
PSWired
Posts: 9
Joined: Tue Jun 29, 2010 2:18 am

Post by PSWired »

Ah yes, I am running chrome as well.
bitviper
Posts: 10
Joined: Mon Aug 27, 2007 10:41 pm

Post by bitviper »

This error got me in 1.24 and I use Chrome. IE8 works fine.
jnmacd
Posts: 7
Joined: Sun Sep 12, 2010 1:00 am

Post by jnmacd »

any fix for this yet?
not working in Chrome for me either. This is causing a lot of problems! Very odd how this is browser specific considering php is server side

edit: a work around is to just copy/paste the URL into a new tab, and manually edit the eid parameter to the # of the event.

i.e.
the failed url is
http://192.168.1.10/zm/index.php?view=v ... =undefined
copy and paste and change it to
http://192.168.1.10/zm/index.php?view=video&eid=273

This seems to work for exporting, making videos, and viewing frames
steffan
Posts: 11
Joined: Sun Apr 17, 2011 6:50 pm

Re: undefined Id in Php and need help to fix

Post by steffan »

Hi guys, i have the same problem.. anyone found a fix for this yet ???

works in ie but not chrome..
Locked