Forums

update query also adding new blank record

ugly 09 Dec, 2009
I have the following code behind the on submit button. This works the value that the user has selected from a list box gets updated But a new blank record is being added as well each time the form gets submitted?? Thanks for any help on this.


<?php
$userid = $_POST['select_5'];
$db =& JFactory::getDBO();
$query = sprintf("UPDATE jos_eventlist_events SET frontpageimage = 'astring' WHERE id = $userid");
$db->setQuery($query);
$db->query();
?>
ugly 09 Dec, 2009
This is part of the debug trace I'm receiving when submitting the form. I'm guessing the bit marked in red is adding the empty record??

#
SELECT *
FROM `jos_chrono_contact_plugins`
WHERE `form_id` = '18'
AND event IN ('ONSUBMIT','ONLOADONSUBMIT')
AND `name` = ''
#
SELECT *
FROM `jos_chrono_contact`
WHERE `id` = '18'
#
UPDATE jos_eventlist_events
SET frontpageimage = 'astring'
WHERE id = 2
#
SELECT *
FROM `jos_chrono_contact`
WHERE `id` = '18'
#
INSERT INTO `jos_eventlist_events` ( )
VALUES ( )
GreyHead 09 Dec, 2009
Hi ugly,

Do you have the ChronoForms Autogenerated save enabled as well?

Bob
ugly 09 Dec, 2009
I've realised my error:Under the db tab I had data storage enabled for the events table, this forced the inclusion of a blank row. I knocked off the data storage and it seems to work ok.
This topic is locked and no more replies can be posted.