custom error message

Hello again everyone, time for another question :wink:,

      On the scheduler, when an error happens server-side, it pops a window with "BAD XML"... which is not helpful at all in figuring out what's wrong. Is there a way to get it to pop a more significant error message when something bad happens?

Thanks in advance,

Osu

If you are using connector - you can enable logging. So you will have detailed error info in log.
On client side you can use

dhtmlxError.catchError("LoadXML", function(){ //do something })

it will block ā€œincorrect xmlā€ alert

The problem I have is that all of my treatment’s custom… so the logging is useless. And then this:

dhtmlxError.catchError("LoadXML", function(){
   //do something
})

Probably won’t help me because, client-side, I have no way of knowing what error happened server-side… and the function defined to catch errors in the example above doesn’t seem to receive any parameter, so…

At this point, I think I’ll explain my current situation, it’ll probably be easier for you to understand. I’m currently trying to implement filters on the calendar. So, for the loading of events, I’ve switched from using ā€œrender_tableā€ to ā€œrender_sqlā€.

So I basically have to redefine all of the basic database operations(INSERT, UPDATE, DELETE). Since I already have an event on my calendar, I decided to start with the update statement. However, the moment I click on ā€œsaveā€, I get the message ā€œincorrect xmlā€ with absolutely no idea what really happened. Since I did not change anything in the code from the time I used ā€œrender_tableā€, the problem, of course comes from the fact that I’m now using ā€œrender_sqlā€ā€¦ but without having a detailed error message, I have no way of knowing what’s wrong and fix the problem.

This is basically why I’m trying to get a custom error message so that I can figure out what’s wrong.

Thanks in advance :slight_smile:.

Osu

Hello,

Most likely something is wrong in your UPDATE SQL query. To verify this you need to enable log in your events.php file:

$scheduler->enable_log("log.txt",true);

Then try to update any information in the scheduler and check this file. There you will find complete SQL query which was used.

Best regards,
Ilya

Here’s what I do:


function myUpdate($action)
	{
		global $ancienTodo;
		
		$requete = "SELECT * FROM tblpmtodo WHERE TodoId = " . $action->get_id();
		$resultat = mysql_query($requete);
		
		$ligne = mysql_fetch_array($resultat);
		
		$ancienTodo = array();
		
		$ancienTodo['Titre'] = $ligne['Titre'];
		$ancienTodo['Description'] = $ligne['Description'];
		$ancienTodo['Client'] = getNom('tblcartetempsclients', 'NoClient', $ligne['NoClient'], 'NomClient');
		$ancienTodo['Division'] = getNom('tblcartetempsdivisions', 'NoDivision', $ligne['NoDivision'], 'NomDivision');
		$ancienTodo['AssignePar'] = getNom('tblcartetempspersonnes', 'NoPersonne', $ligne['DeNoPersonne'], 'NomPersonne');
		$ancienTodo['StartDateTime'] = substr($ligne['StartDateTime'], 0, strlen($ligne['StartDateTime']) - 3);
		$ancienTodo['EndDateTime'] = substr($ligne['EndDateTime'], 0, strlen($ligne['EndDateTime']) - 3);
		$ancienTodo['Statut'] = getNom('tblpmstatut', 'StatutId', $ligne['StatutId'], 'Statut');
		
		$requete = "UPDATE tblpmtodo SET NoClient = " . $action->get_value('NoClient') . ", " . 
							"NoDivision = " . $action->get_value('NoDivision') . ", " . 
							"Titre = " . mysql_real_escape_string($action->get_value('Titre')) . ", " . 
							"Etiquette = " . mysql_real_escape_string($action->get_value('Etiquette')) . ", " . 
							"Description = \"" . mysql_real_escape_string($action->get_value('Description')) . "\" " .
							"StartDateTime = \"" . $action->get_value('StartDateTime') . "\", " .
							"EndDateTime = \"" . $action->get_value('EndDateTime') . "\", " . 
							"Priorite = " . $action->get_value('Priorite') . ", " . 
							"ANoPersonne = " . $action->get_value('ANoPersonne') . ", " . 
							"StatutId = " . $action->get_value('StatutId') . ", " . 
							"PrcComplete = " . $action->get_value('PrcComplete') . ", " . 
							"CalendrierStrategique = " . $action->get_value('CalendrierStrategique') . " " . 
							"WHERE TodoId = " . $action->get_id();
		$scheduler->sql->query($requete);
		//mysql_query($requete) or die(mysql_error());
		$action->success();
	}
$sqlPrincipal = "SELECT * FROM tblpmtodo INNER JOIN tblpmdestinatairespermissions on tblpmtodo.TodoId = tblpmdestinatairespermissions.TodoId WHERE tblpmdestinatairespermissions.NoPersonne = " . $_SESSION['Employe'];

$scheduler->event->attach("beforeUpdate", "myUpdate");
$scheduler->enable_log("log.txt",true);
$scheduler->render_sql($sqlPrincipal, "TodoId", "StartDateTime,EndDateTime,Etiquette,Description,Titre,ANoPersonne,NoClient,NoDivision,PrcComplete,Priorite,CalendrierStrategique,StatutId");

And inside the log:

====================================
Log started, 03/12/2010 11:12:31
====================================

SELECT  * FROM tblpmtodo INNER JOIN tblpmdestinatairespermissions on tblpmtodo.TodoId = tblpmdestinatairespermissions.TodoId WHERE  tblpmdestinatairespermissions.NoPersonne = 64

SELECT  NoPersonne as value, NomPersonne as label FROM tblcartetempspersonnes WHERE  MembreScheduler = 1 ORDER BY NomPersonne ASC

SELECT  NoClient as value, NomClient as label FROM tblcartetempsclients WHERE  Statut = 1 ORDER BY NomClient ASC

SELECT  0 as value, '' as label FROM tblcartetempsdivisions WHERE  1 union SELECT NoDivision as value, NomDivision as label FROM tblcartetempsdivisions ORDER BY label ASC

Done in 0.012165069580078s



====================================
Log started, 03/12/2010 11:12:39
====================================

DataProcessor object initialized
126_id => 126
126_start_date => 2010-12-01 10:15
126_end_date => 2010-12-01 10:20
126_text => TODO - tfilteau - 126
126_Description => hjjghjgh
126_Titre => 
126_ANoPersonne => 64
126_NoClient => 53
126_NoDivision => 0
126_PrcComplete => 0
126_Priorite => 1
126_CalendrierStrategique => 0
126_StatutId => 1
126_RappelA => 1
126_DateRappelA => 1900-01-01 00:00:00
126_FrequenceRappelA => 0
126_UniteRappelA => 1
126_DroitsA => 3
126_ListeCC => 
126_DateNotificationCC => 
126_DroitCC => 
126_NotificationCC => 
126_FrequenceCC => 
126_UniteFrequenceCC => 
126_CC_length => 0
126_DateRappelGeneral => 1900-01-01 00:00:00
126_FrequenceGenerale => 0
126_FrequenceUniteGeneral => 1
126_DeNomPersonne => Tobbi Filteau
126_DeNoPersonne => 64
126_NotificationA => 1
126_DroitDestinataire => 3
126_!nativeeditor_status => updated
ids => 126

Row data [126]
TodoId => 126
StartDateTime => 2010-12-01 10:15
EndDateTime => 2010-12-01 10:20
Etiquette => TODO - tfilteau - 126
Description => hjjghjgh
Titre => 
ANoPersonne => 64
NoClient => 53
NoDivision => 0
PrcComplete => 0
Priorite => 1
CalendrierStrategique => 0
StatutId => 1
RappelA => 1
DateRappelA => 1900-01-01 00:00:00
FrequenceRappelA => 0
UniteRappelA => 1
DroitsA => 3
ListeCC => 
DateNotificationCC => 
DroitCC => 
NotificationCC => 
FrequenceCC => 
UniteFrequenceCC => 
CC_length => 0
DateRappelGeneral => 1900-01-01 00:00:00
FrequenceGenerale => 0
FrequenceUniteGeneral => 1
DeNomPersonne => Tobbi Filteau
DeNoPersonne => 64
NotificationA => 1
DroitDestinataire => 3
!nativeeditor_status => updated

As you can see, there’s no mention of SQL anywhere. If you could point me in the right direction, I’d be really grateful.

Thanks in advance.

Osu

Hello,

$scheduler->sql->query($requete); //mysql_query($requete) or die(mysql_error()); $action->success();
Replace with:

global $scheduler; $scheduler->sql->attach("Update",$requete);
Also now information about query should be in the logs.

Hope this helps.
Best regards,
Ilya

Well, I’ve tried what you suggested and it still doesn’t work. What’s more, there’s nothing in the logs to show any SQL being executed. Here’s the log:



====================================
Log started, 06/12/2010 10:12:18
====================================

DataProcessor object initialized
126_id => 126
126_start_date => 2010-12-01 10:15
126_end_date => 2010-12-01 10:20
126_text => TODO - tfilteau - 126
126_Description => hjh
126_Titre => 
126_ANoPersonne => 64
126_NoClient => 53
126_NoDivision => 0
126_PrcComplete => 0
126_Priorite => 1
126_CalendrierStrategique => 0
126_StatutId => 1
126_RappelA => 1
126_DateRappelA => 1900-01-01 00:00:00
126_FrequenceRappelA => 0
126_UniteRappelA => 1
126_DroitsA => 3
126_ListeCC => 
126_DateNotificationCC => 
126_DroitCC => 
126_NotificationCC => 
126_FrequenceCC => 
126_UniteFrequenceCC => 
126_CC_length => 0
126_DateRappelGeneral => 1900-01-01 00:00:00
126_FrequenceGenerale => 0
126_FrequenceUniteGeneral => 1
126_DeNomPersonne => Tobbi Filteau
126_DeNoPersonne => 64
126_NotificationA => 1
126_DroitDestinataire => 3
126_!nativeeditor_status => updated
ids => 126

Row data [126]
TodoId => 126
StartDateTime => 2010-12-01 10:15
EndDateTime => 2010-12-01 10:20
Etiquette => TODO - tfilteau - 126
Description => hjh
Titre => 
ANoPersonne => 64
NoClient => 53
NoDivision => 0
PrcComplete => 0
Priorite => 1
CalendrierStrategique => 0
StatutId => 1
RappelA => 1
DateRappelA => 1900-01-01 00:00:00
FrequenceRappelA => 0
UniteRappelA => 1
DroitsA => 3
ListeCC => 
DateNotificationCC => 
DroitCC => 
NotificationCC => 
FrequenceCC => 
UniteFrequenceCC => 
CC_length => 0
DateRappelGeneral => 1900-01-01 00:00:00
FrequenceGenerale => 0
FrequenceUniteGeneral => 1
DeNomPersonne => Tobbi Filteau
DeNoPersonne => 64
NotificationA => 1
DroitDestinataire => 3
!nativeeditor_status => updated

And of course, here’s the code:

function myUpdate($action)
	{
		global $ancienTodo;
		global $scheduler;
		$requete = "SELECT * FROM tblpmtodo WHERE TodoId = " . $action->get_id();
		$resultat = mysql_query($requete);
		
		$ligne = mysql_fetch_array($resultat);
		
		$ancienTodo = array();
		
		$ancienTodo['Titre'] = $ligne['Titre'];
		$ancienTodo['Description'] = $ligne['Description'];
		$ancienTodo['Client'] = getNom('tblcartetempsclients', 'NoClient', $ligne['NoClient'], 'NomClient');
		$ancienTodo['Division'] = getNom('tblcartetempsdivisions', 'NoDivision', $ligne['NoDivision'], 'NomDivision');
		$ancienTodo['AssignePar'] = getNom('tblcartetempspersonnes', 'NoPersonne', $ligne['DeNoPersonne'], 'NomPersonne');
		$ancienTodo['StartDateTime'] = substr($ligne['StartDateTime'], 0, strlen($ligne['StartDateTime']) - 3);
		$ancienTodo['EndDateTime'] = substr($ligne['EndDateTime'], 0, strlen($ligne['EndDateTime']) - 3);
		$ancienTodo['Statut'] = getNom('tblpmstatut', 'StatutId', $ligne['StatutId'], 'Statut');
		
		$requete = "UPDATE tblpmtodo SET NoClient = " . $action->get_value('NoClient') . " " . 
							"NoDivision = " . $action->get_value('NoDivision') . ", " . 
							"Titre = " . mysql_real_escape_string($action->get_value('Titre')) . ", " . 
							"Etiquette = " . mysql_real_escape_string($action->get_value('Etiquette')) . ", " . 
							"Description = \"" . mysql_real_escape_string($action->get_value('Description')) . "\" " .
							"StartDateTime = \"" . $action->get_value('StartDateTime') . "\", " .
							"EndDateTime = \"" . $action->get_value('EndDateTime') . "\", " . 
							"Priorite = " . $action->get_value('Priorite') . ", " . 
							"ANoPersonne = " . $action->get_value('ANoPersonne') . ", " . 
							"StatutId = " . $action->get_value('StatutId') . ", " . 
							"PrcComplete = " . $action->get_value('PrcComplete') . ", " . 
							"CalendrierStrategique = " . $action->get_value('CalendrierStrategique') . " " . 
							"WHERE TodoId = " . $action->get_id();
		//$scheduler->sql->query($requete);
		//mysql_query($requete) or die(mysql_error());
		$scheduler->sql->attach("update",$requete); //With or without capital 'U' it doesn't do anything
		//$action->success();
	}

$scheduler->event->attach("beforeUpdate", "myUpdate");

What’s more, even if I comment the whole code, I still get an error… which is understandably frustrating since the error message does not tell me what’s wrong.

Anyway, any sort of help will be greatly appreciated.

Thank you

While testing locally I have got a similar log response - it was caused by missed getNom function ( which results in non-catchable fatal error ) , after adding such function - connector code execs custom sql for sure.

You guys positively rock, there’s no other way to put it!!! :smiley:

While, in this particular case, the error did not lie with the missing getNom function since I did indeed have it in my complete code, it did lead me to look at all the places I was actually using it and it made me find this little line:

$ancienTodo['AssignePar'] = getNom('tblcartetempspersonnes', 'NoPersonne', $ligne['DeNoPersonne'], 'NomPersonne');

While this line doesn’t present any problem in and of itself, I forgot that the field ā€œDeNoPersonneā€ NO LONGER EXISTS in my central table!!! So this is why everything was crashing… honestly, sometimes I feel like an idiot, but thanks to your pointer, I was able to find what was going on and now it works perfectly :smiley:

Thanks again

Osu