Trying to update a db record

t1gra1rma1@ 09 Mar, 2012
Hello,

I am trying to update a db record when a user uses the submit button but that is not possible. I am using a custom code on submit event which is the following:


<?php
$db =& JFactory::getDBO();
$user = JFactory::getUser();
$query = "
  UPDATE `#dtsjoom_chronoforms_data_editable_test`
    SET `editable` = `0`
    WHERE `cf_user_id` = ".$user->id." ;
";
$db->setQuery($query);
$db->query();
?>


Any help pls?

And one more question. if i add an event (lets call it On test) and then create a menu item that points to a chronoform form and put test on event then when i use the menu item it should execute the code on test event right? cause i tried this too but it didnt work


Thank you in advance
GreyHead 09 Mar, 2012
Hi t1gra1rma1@,

This doesn't look like a valid table name `#dtsjoom_chronoforms_data_editable_test`. I suggest you use the ChronoForms DB Save action instead.

if i add an event (lets call it On test) and then create a menu item that points to a chronoform form and put test on event then when i use the menu item it should execute the code on test event right? cause i tried this too but it didnt work



Works OK here - what code did you use?

Bob
t1gra1rma1@ 09 Mar, 2012
i am using a db loader to check if the user is logged and get his cf_user_id. if yes there is a show html, if no there is a thank you message.

dtsjoom_chronoforms_data_editable_test is my full table name.

dtsjoom is my joomla database prefix and my table is chronoforms_data_editable_test.
GreyHead 09 Mar, 2012
Hi t1gra1rma1@,

As I said the table name is incorrect; it should either be `#__chronoforms_data_editable_test` or `dtsjoom_chronoforms_data_editable_test`

I don't think that a Show HTML action will do anything on a custom event; try an Event Loop pointing to > On Load instead.


Bob
This topic is locked and no more replies can be posted.