Forums

Database not being updated

philstan 18 Mar, 2009
First of all, let me thank you guys for an EXCELLENT component. So much better than anything else for Joomla or Drupal.

I have created 2 forms with the ChronoForm. Both these forms were working quite smoothly and the update to the database was functioning well. However, each of these forms is compiling survey information which must be unique to the user and not the form id (cf_id). So in phpMyAdmin I changed the Primary key from the cf_id to a new field (j_id which is a hidden field within the form taking its value from Joomla) to allow for an automatic replace or update. Also I have added another hidden field to add an arbitrary value for cf_id (it is no longer auto increment). Here is the code within the body of the form:

<?php
$user =& JFactory::getUser();
$usrId = $user->get( 'id' );
echo '<input type="hidden" name="j_id" value="' . $usrId . '" />';
echo '<input type="hidden" name="cf_id" value=0 />';

?>
philstan 19 Mar, 2009
In re-reading my post it seems the last bit dropped out (the most important bit!).

Anyway, the problem is that the database is no longer updating (it did work a couple of times), although in debug mode I can see the correct information being passed. Also, I receive NO error message from the DB which really has me scratching my head.

** I have just recreated the forms and am getting the same result: It works a few times and then stops updating or accepting new records, even though debug shows that it is being passed. Argh!

Any thoughts?

I'm using:

Chronoforms 3.1 rc2
Joomla 1.5.9
GreyHead 19 Mar, 2009
Hi philstan,

I think if you turn Site Debug on then you will see the SQL queries that are being created. I suspect that you may still have cf_id defined as unique???

Bob
philstan 19 Mar, 2009
Hi Bob,

Thank you for your quick response.

I think your idea is a good one. However, I deleted the cf_id field and re-created it as not unique (unless I'm doing something wrong here) and am still getting the same response.

Here is the relevant SQL that's being created (but not hitting the DB):

#
UPDATE `jos_chronoforms_Gift_test2`
SET `cf_id`='0',`uid`='IZTg1OTU2NWQ3YTM2',`recordtime`='2009-03-19 - 01:11:56',`ipaddress`='66.183.145.126',`cf_user_id`='69',`A1`='0',`E1`='0',`M1`='0',`L1`='0',`En1`='0',`A2`='0',`F1`='0',
WHERE j_id='69'
GreyHead 19 Mar, 2009
Hi philstan,

That looks OK (with the possible exception that j_id isn't quoted).

What error do you get if you paste that query into PHPMyAdmin?

Bob
philstan 19 Mar, 2009
Excellent suggestion.

Well, I just ran the full SQL and received NO ERRORS from phpmyadmin! However, it still shows nothing in the table!?!?!?

What on Earth is going on?

Here's a screenshot. Please note the greyed out "Browse" tab

GreyHead 19 Mar, 2009
Hi philstan,

If there's no Browse, then presumably there are no records and so nothing to update. Try REPLACE instead of UPDATE?

Bob
philstan 19 Mar, 2009
Thank you Bob.

I have been having this issue even when there were records from the initial successful updates (don't forget, it did work a couple of times initially). However, I just tried it with REPLACE and received the following SQL error:

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE 'j_id'='69'' at line 3

Thx Philip
GreyHead 19 Mar, 2009
Hi philstan,

You have straight quotes round 'j_id' - should be backticks `j_id`

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

VPS & Email Hosting 20% discount

{item:title} {images:#}