data['dealer_id'] = $dealer_id ; ?>All necessary values to execute the query should be obtained with the line $db = JFactory::getDBO();It should return the values for the new website on which it is run. However, when this script is run in the form on the new website, it returns an error message: Error in query: SELECT MAX(id) FROM jos_locations. Access denied for user 'user'@'localhost' (using password: NO)The user@localhost in the error messages includes user details from the website from which the form was backupped (removed here for safety reasons). My conclusion is that either form or the backup stores website related information that is not replaced when importing the form on a new website. As such, this limits the backup and restore function quite a bit😟 .Have I overlooked something here, or is this a limitation or a bug ?Thank you and best regards fromErik"> Imported forms uses original website's details? - Forums

Forums

Imported forms uses original website's details?

Erik66 23 Mar, 2014
Hello,

Using Chronoforms V4 (lates version) I tried backing up and restoring a form from one J2.5.19 website to another. The form itself uses a custom script to fetch a value from a table in the database and put that into a new form->data[] key. The PHP script run looks as follows:

<?php
$dealer_id = 0 ;
$db = JFactory::getDBO();
$query = "SELECT MAX(id) FROM jos_locations";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
$row = mysql_fetch_row($result);
$dealer_id = $row[0] + 1 ;
$form->data['dealer_id'] = $dealer_id ;
?>

All necessary values to execute the query should be obtained with the line

$db = JFactory::getDBO();

It should return the values for the new website on which it is run. However, when this script is run in the form on the new website, it returns an error message:

Error in query: SELECT MAX(id) FROM jos_locations. Access denied for user 'user'@'localhost' (using password: NO)

The user@localhost in the error messages includes user details from the website from which the form was backupped (removed here for safety reasons).

My conclusion is that either form or the backup stores website related information that is not replaced when importing the form on a new website. As such, this limits the backup and restore function quite a bit😟 .

Have I overlooked something here, or is this a limitation or a bug ?

Thank you and best regards from

Erik
GreyHead 23 Mar, 2014
Hi Erik,

It's a bug in your code. You define $db but - as far as I can see - it is never used. And as you aren't using the Joomla! DBO object you need to setup a username and password before using PHP functions like mysql_query()

Bob
Erik66 23 Mar, 2014
Hell Greyhead,

thanks for your reply. If it true what you are writing (which I most certainly believe) then why does this at all work on the site this was originally backupped from ? I don't get it. If the method used is in principle incorrect, it should not work on the original website either. But it does. I'm puzzled ...

Best regards from

Erik
GreyHead 23 Mar, 2014
Hi Erik,

I don't know how or why it worked before, just that you tell me it's not working now.

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