elari Posted November 29, 2002 Share Posted November 29, 2002 while in admin customers when i want to edit a customer Warning: Variable passed to reset() is not an array or object in /usr/local/apache/htdocs/unlockgsm/nh3/admin/includes/classes/object_info.php on line 17 Warning: Variable passed to each() is not an array or object in /usr/local/apache/htdocs/unlockgsm/nh3/admin/includes/classes/object_info.php on line 18 this is part of code in customers.php if ($HTTP_GET_VARS['action'] == 'edit') { $customers_query = tep_db_query("select c.customers_gender,c.customers_status, c.member_flag, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . $HTTP_GET_VARS['cID'] . "'"); $customers = tep_db_fetch_array($customers_query); echo 'test' . $customers_query . $customers; $cInfo = new objectInfo($customers); $customers_query echo as a ressource $customers echo as empty... any idea to search for ???? and in catalog customers value are not reported while they are ok in database.. may someone create account here and tell me if he can update his account ? http://www.unlockgsm.com/nh3/catalog/default.php thanks Link to comment Share on other sites More sharing options...
elari Posted November 29, 2002 Author Share Posted November 29, 2002 and more strange.... it work for the original default customers John Doe only all othes make errors Link to comment Share on other sites More sharing options...
jdames Posted December 4, 2003 Share Posted December 4, 2003 Bump! I too am having this issue? Could it be a magic-quotes = Off; setting in my php.ini that is causing this? Thanks, Joe Link to comment Share on other sites More sharing options...
Guest Posted December 5, 2003 Share Posted December 5, 2003 did u do a upgradation from ms1 to ms2 ? Link to comment Share on other sites More sharing options...
beardeddone Posted December 5, 2003 Share Posted December 5, 2003 while in admin customers when i want to edit a customer Warning: Variable passed to reset() is not an array or object in /usr/local/apache/htdocs/unlockgsm/nh3/admin/includes/classes/object_info.php on line 17 Warning: Variable passed to each() is not an array or object in /usr/local/apache/htdocs/unlockgsm/nh3/admin/includes/classes/object_info.php on line 18 This error usually only accurs when a customer doesn't choose a default address checkbox when they sign up, I had this same problem and narrowed it down to this, I had a user add an address and had him be sure to put a check in the check box and continue and delete the old address and it worked.. No more error for him in admin. The problem with OSC MS2 is that in the catalog/includes/modules/address_book_details.php this code near the bottom of the page <td colspan="2" class="main"><?php echo tep_draw_checkbox_field('primary', 'on', false, 'id="primary"') . ' ' . SET_AS_PRIMARY; ?></td> is defaulted wrong It should be <td colspan="2" class="main"><?php echo tep_draw_checkbox_field('primary', 'on', true, 'id="primary"') . ' ' . SET_AS_PRIMARY; ?></td> then you won't have this problem again, hopefully. Best Regards Link to comment Share on other sites More sharing options...
jdames Posted December 5, 2003 Share Posted December 5, 2003 OK... I think I've figured out what happened. How or why it happened, I have a guess. Here's the jist of it: My customers were all listed as having the valuecustomers_default_address_id in the customers table = 1. This caused a customers_id lookup against the address_book to fail. You see, in the customers database, each record has a a customers_id which uniquely identifies each customer. Each customer record also has a field named customers_default_address_id which refers to the address_book table. This field defines their defaul address in their addressbook. In the address_book table the customers_id field is an indexed key that must match the customers_id field from the customers table when a query tries to retrieve the addressbook options for said customer. I think this may have been caused by an upgrade from MS1 to MS2. I wrote this to try to fix the problem. It just grabs the first address with a matching customers_id and then copies that address_book_id and copies it to that users customers_default_address_id in the customers table. Here it is (BACKUP YOUR DATABASE FIRST BEFORE RUNNING THIS SCRIPT! I hope it works right for you! It worked right for me. Just change the datbase connection user/pass stuff): <html><head><title>Customer Default Address Fixer</title></head> <body> Customer Default Address Fixer <br> <? ######Define Database $dbserver = mysql_connect('localhost','mysqluser','mysqlpass') or die("Wha' Happen??? Could Not Connect"); $dbname = mysql_select_db('databasename',$dbserver) or die("Wha' Happen??? Could Not Select DB"); ######Query 1 $customersrecords = mysql_query("SELECT * FROM customers") or die ("Wha' Happen??? Error 1"); ######Column Headers For Table echo "<br>\n"."Customer found to potentially update: ".mysql_num_rows($customersrecords); echo "<br>\n"."<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" bordercolor=\"000000\">"; echo "\n"." <tr> <td>customers.customers_id</td> <td>customers.Name</td> <td>customers.customers_default_address_id</td> <td>RecordsUpdated</td> </tr>" ; ######Print Query 1 results and table update to replace each customers_default_address_id with the first listed address_book_id from the address_book while($customerrows = mysql_fetch_assoc($customersrecords)) { echo "\n"."<tr><td align=\"center\">".$customerrows[customers_id]."</td>"; echo "<td align=\"center\">".$customerrows['customers_firstname']."</td>"; echo "<td align=\"center\">".$customerrows['customers_default_address_id']."</td>"; $e = mysql_query("SELECT * FROM address_book WHERE customers_id ='$customerrows[customers_id]'") or die ("Wha' Happen??? Error 2"); $real = mysql_fetch_assoc($e); $updatedefaultaddress = mysql_query("UPDATE customers SET customers_default_address_id = '$real[address_book_id]' WHERE customers_id='$customerrows[customers_id]'") or die ("Wha' Happen??? Error 3"); echo "<td align=\"center\">".mysql_affected_rows()."</td></tr>"; } ?> </table> </body> </html> Hope this helps, Joe Link to comment Share on other sites More sharing options...
Guest Posted December 21, 2003 Share Posted December 21, 2003 while in admin customers when i want to edit a customer Warning: Variable passed to reset() is not an array or object in /usr/local/apache/htdocs/unlockgsm/nh3/admin/includes/classes/object_info.php on line 17 Warning: Variable passed to each() is not an array or object in /usr/local/apache/htdocs/unlockgsm/nh3/admin/includes/classes/object_info.php on line 18 This error usually only accurs when a customer doesn't choose a default address checkbox when they sign up, I had this same problem and narrowed it down to this, I had a user add an address and had him be sure to put a check in the check box and continue and delete the old address and it worked.. No more error for him in admin. The problem with OSC MS2 is that in the catalog/includes/modules/address_book_details.php this code near the bottom of the page <td colspan="2" class="main"><?php echo tep_draw_checkbox_field('primary', 'on', false, 'id="primary"') . ' ' . SET_AS_PRIMARY; ?></td> is defaulted wrong It should be <td colspan="2" class="main"><?php echo tep_draw_checkbox_field('primary', 'on', true, 'id="primary"') . ' ' . SET_AS_PRIMARY; ?></td> then you won't have this problem again, hopefully. Thanks !!!!!!! Link to comment Share on other sites More sharing options...
beardeddone Posted December 21, 2003 Share Posted December 21, 2003 OK... I think I've figured out what happened. How or why it happened, I have a guess. Here's the jist of it: My customers were all listed as having the valuecustomers_default_address_id in the customers table = 1. This caused a customers_id lookup against the address_book to fail. You see, in the customers database, each record has a a customers_id which uniquely identifies each customer. Each customer record also has a field named customers_default_address_id which refers to the address_book table. This field defines their defaul address in their addressbook. In the address_book table the customers_id field is an indexed key that must match the customers_id field from the customers table when a query tries to retrieve the addressbook options for said customer. I think this may have been caused by an upgrade from MS1 to MS2. I wrote this to try to fix the problem. It just grabs the first address with a matching customers_id and then copies that address_book_id and copies it to that users customers_default_address_id in the customers table. Here it is (BACKUP YOUR DATABASE FIRST BEFORE RUNNING THIS SCRIPT! I hope it works right for you! It worked right for me. Just change the datbase connection user/pass stuff): <html><head><title>Customer Default Address Fixer</title></head> <body> Customer Default Address Fixer <br> <? ######Define Database $dbserver = mysql_connect('localhost','mysqluser','mysqlpass') or die("Wha' Happen??? Could Not Connect"); $dbname = mysql_select_db('databasename',$dbserver) or die("Wha' Happen??? ?Could Not Select DB"); ######Query 1 $customersrecords = mysql_query("SELECT * FROM customers") or die ("Wha' Happen??? Error 1"); ######Column Headers For Table echo "<br>\n"."Customer found to potentially update: ".mysql_num_rows($customersrecords); echo "<br>\n"."<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" bordercolor=\"000000\">"; echo "\n"." <tr> <td>customers.customers_id</td> <td>customers.Name</td> <td>customers.customers_default_address_id</td> <td>RecordsUpdated</td> </tr>" ; ######Print Query 1 results and table update to replace each customers_default_address_id with the first listed address_book_id from the address_book while($customerrows = mysql_fetch_assoc($customersrecords)) { echo "\n"."<tr><td align=\"center\">".$customerrows[customers_id]."</td>"; echo "<td align=\"center\">".$customerrows['customers_firstname']."</td>"; echo "<td align=\"center\">".$customerrows['customers_default_address_id']."</td>"; ? ?$e = mysql_query("SELECT * FROM address_book WHERE customers_id ='$customerrows[customers_id]'") or die ("Wha' Happen??? Error 2"); $real = mysql_fetch_assoc($e); $updatedefaultaddress = mysql_query("UPDATE customers SET customers_default_address_id = '$real[address_book_id]' WHERE customers_id='$customerrows[customers_id]'") or die ("Wha' Happen??? Error 3"); echo "<td align=\"center\">".mysql_affected_rows()."</td></tr>"; } ?> </table> </body> </html> Hope this helps, Joe What file does this code go in? Best Regards Link to comment Share on other sites More sharing options...
jdames Posted December 22, 2003 Share Posted December 22, 2003 <html><head><title>Customer Default Address Fixer</title></head> <body> Customer Default Address Fixer <br> <? ######Define Database $dbserver = mysql_connect('localhost','mysqluser','mysqlpass') or die("Wha Happen??? Could Not Connect"); $dbname = mysql_select_db('databasename',$dbserver) or die("Wha Happen??? Could Not Select DB"); ######Query 1 $customersrecords = mysql_query("SELECT * FROM customers") or die ("Wha Happen??? Error 1"); ######Column Headers For Table echo "<br>\n"."Customer found to potentially update: ".mysql_num_rows($customersrecords); echo "<br>\n"."<table cellspacing=\"0\" cellpadding=\"0\" border=\"1\" bordercolor=\"000000\">"; echo "\n"." <tr> <td>customers.customers_id</td> <td>customers.Name</td> <td>customers.customers_default_address_id</td> <td>RecordsUpdated</td> </tr>" ; ######Print Query 1 results and table update to replace each customers_default_address_id with the first listed address_book_id from the address_book while($customerrows = mysql_fetch_assoc($customersrecords)) { echo "\n"."<tr><td align=\"center\">".$customerrows[customers_id]."</td>"; echo "<td align=\"center\">".$customerrows['customers_firstname']."</td>"; echo "<td align=\"center\">".$customerrows['customers_default_address_id']."</td>"; $e = mysql_query("SELECT * FROM address_book WHERE customers_id ='$customerrows[customers_id]'") or die ("Wha Happen??? Error 2"); $real = mysql_fetch_assoc($e); $updatedefaultaddress = mysql_query("UPDATE customers SET customers_default_address_id = '$real[address_book_id]' WHERE customers_id='$customerrows[customers_id]'") or die ("Wha Happen??? Error 3"); echo "<td align=\"center\">".mysql_affected_rows()."</td></tr>"; } ?> </table> </body> </html> It is it's own file. You only need to name it and then goto it in your browser. Please make sure that my situation is the same as yours. You'll have to look at the tables I mentioned to insure this. I really don't want anyone to screw up there db due to my advice not being pertinent. Good luck. Link to comment Share on other sites More sharing options...
beardeddone Posted December 22, 2003 Share Posted December 22, 2003 Ok, but it needs to be incorporated into OSC some where, would you be more specific if you will, can't just put this code anywhere. Thanks Best Regards Link to comment Share on other sites More sharing options...
Guest Posted January 21, 2004 Share Posted January 21, 2004 thanks I named the code upgrade_address.php and ran it and worked a treat... Link to comment Share on other sites More sharing options...
HQ Secure Posted March 30, 2004 Share Posted March 30, 2004 Great bandaid. Doesn't solve the problem. Link to comment Share on other sites More sharing options...
HQ Secure Posted April 26, 2004 Share Posted April 26, 2004 I put in the customer address fixer and modified the code in catalog/includes/modules/address_book_details.php This is what a new customer signing up sees when they go to checkout: Link to comment Share on other sites More sharing options...
devink Posted April 30, 2004 Share Posted April 30, 2004 This is definitely an upgrade issue. But even new customers get the problem, not just old ones. I have craeted a brand new store, and upgraded one in the last couple of months. The new doesn't have this problem but the upgraded one does. Sorry, my PHP isn't good enough to fix the problem. Many Thanks, Steve Link to comment Share on other sites More sharing options...
devink Posted April 30, 2004 Share Posted April 30, 2004 OK! I've found a difference by comparing one database against the other. In the new DB, address_book_id is set to autoincrement, in the upgraded one it isn't. In the new DB, each address_book_id is unique, in the upgrade, every address_book_id is 1. The default address is also 1 in the customers table, but it's still an issue. I guess customer number must be irrelevant in the lookup. So...how do we fix this? Many Thanks, Steve Link to comment Share on other sites More sharing options...
devink Posted April 30, 2004 Share Posted April 30, 2004 Sorry, I can't edit posts... Right, I've fixed it, but I used Microsoft Access to correct the data, and PHPmyAdmin to fix the table. To fix the data... UPDATE address_book SET address_book_id = customers_id This fixed 95% of entries, I had to manually correct addresses where the cstomer had extra addresses. UPDATE customers SET customers_default_address_id = customers_id Now all customers are using the first address as the default address. In PHPmyAdmin I changed teh field to AutoIncrement. I created a new customer, and it worked straight away. Hope this helps somebody somewhere! Many Thanks, Steve Link to comment Share on other sites More sharing options...
goodolandy Posted May 18, 2004 Share Posted May 18, 2004 Hello devink, I just have a question or two about the two edits you mention in your last post. When you say; "UPDATE address_book" and "UPDATE customers", are talking about the .php files under the main directory? And when you say; "SET address_book_id = customers_id" and "SET customers_default_address_id = customers_id" Is that exactly what should be typed in respected .php files? If yes to both then does it matter where the "SET" lines are placed in the respected .php file? Andrew Link to comment Share on other sites More sharing options...
pianowoman Posted March 3, 2005 Share Posted March 3, 2005 jdames, I just have to say THANK YOU! This worked like a dream. I searched the forum for almost two hours. I saw people having the exact same problem but with no real solutions. You should add this to the osc Contributions! Kudos to you! :thumbsup: Link to comment Share on other sites More sharing options...
Logisyscorp Posted March 18, 2005 Share Posted March 18, 2005 Sorry, I can't edit posts... Right, I've fixed it, but I used Microsoft Access to correct the data, and PHPmyAdmin to fix the table. To fix the data... UPDATE address_book SET address_book_id = customers_id This fixed 95% of entries, I had to manually correct addresses where the cstomer had extra addresses. UPDATE customers SET customers_default_address_id = customers_id Now all customers are using the first address as the default address. In PHPmyAdmin I changed teh field to AutoIncrement. I created a new customer, and it worked straight away. Hope this helps somebody somewhere! <{POST_SNAPBACK}> Hi! I found your solution might fix the problem we have same encounter. Would you please kindly post us the detail step to fix the problem. Such as where to update customers , where to update the address-book. UPDATE address_book SET address_book_id = customers_id This fixed 95% of entries, I had to manually correct addresses where the cstomer had extra addresses. UPDATE customers SET customers_default_address_id = customers_id Now all customers are using the first address as the default address. In PHPmyAdmin I changed teh field to AutoIncrement Many thanks! Sharon Link to comment Share on other sites More sharing options...
devink Posted March 23, 2005 Share Posted March 23, 2005 Hi Sharon, the problem is that when you upgrade, there is a new field in the address book table, named address_book. The new field is address_book_id, and MUST be unique. So if you have 100 addresses, they need to be numbered 1 to 100, for example. You could do this in MySQL admin, but you will need to go into every record in the address book and update it. You could also run the SQL statement. I did it in Microsoft Access, but it should work in MySQL admin too. The second SQL statement is used to make sure every customer has a default address. Old customers logging on to the new site will not have a default address, and will have to select it again. To make sure the customer is not inconvenienced, you must associate the customer record with the address book record again. It should work in MySQL admin again, I just haven't tested it. Don't forget to backup data before making changes!!! Many Thanks, Steve Link to comment Share on other sites More sharing options...
Logisyscorp Posted March 30, 2005 Share Posted March 30, 2005 Steve, thanks for your reply! I still don't understand it. What do I need to do with these 2 formular: How do I need to do to "set address_book_id= customer_id", what do I need to change in PHPmyAdmin table? So, does the "update customer file"? Can you tell us step by step? Thanks Sharon UPDATE address_bookSET address_book_id = customers_id This fixed 95% of entries, I had to manually correct addresses where the cstomer had extra addresses. UPDATE customers SET customers_default_address_id = customers_id Now all customers are using the first address as the default address. In PHPmyAdmin I changed teh field to AutoIncrement Hi Sharon, the problem is that when you upgrade, there is a new field in the address book table, named address_book. The new field is address_book_id, and MUST be unique. So if you have 100 addresses, they need to be numbered 1 to 100, for example. You could do this in MySQL admin, but you will need to go into every record in the address book and update it. You could also run the SQL statement. I did it in Microsoft Access, but it should work in MySQL admin too. The second SQL statement is used to make sure every customer has a default address. Old customers logging on to the new site will not have a default address, and will have to select it again. To make sure the customer is not inconvenienced, you must associate the customer record with the address book record again. It should work in MySQL admin again, I just haven't tested it. Don't forget to backup data before making changes!!! <{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
Guest Posted April 10, 2005 Share Posted April 10, 2005 There are a lot of responses to this problem and some of them are dangerously inaccurate. The few solutions that have been offered are only for existing records, new customers would still experience the problem. Firstly, don't autonumber the address_book_id field this should be numbered 1 for each customer and represents the first address in their address book. The customers_default_address_id in the customers table should usually be 1 unless they have choosen a different primary address from their address book. So why are the addresses appearing blank when a customer creates an account to go to checkout? The answer is that when an account is created the address_book table is being filled with their address under their customer number and given the address_book_id of 1 (as it should be) At the same time a customer record is written to the customer table but the customers_default_address_id is being set to 0 instead of 1 and as no address_book_id with a value of 0 exists for the customer no address is entered in the checkout procedure. My problem is that I can't find where this 0 rating is being entered into the Database and the default value for this field in MySQL is 1 so the store itself is changing the value. Link to comment Share on other sites More sharing options...
Guest Posted April 10, 2005 Share Posted April 10, 2005 OK, I've played with it a bit and found a quick solution. This probably only effects those who have migrated customer data from an older version of the store. In MySQL set the default value for the address_book_id field in the address_book table to 0 instead of 1 and the addresses will appear for new customers. If you have already received orders where there are no customer details you will have to bite the bullet and enter them manually directly into the database. Remeber that although no address details have been entered into the orders they do exist in the customer records in the database. Link to comment Share on other sites More sharing options...
Logisyscorp Posted April 13, 2005 Share Posted April 13, 2005 Andy, It does fix half of the problem after change to "0". However, If click button "change address" on delivery information, it won't take 2nd shipping address, and it won't let you get out the page of edit shipping address. In other word, It won't take 2nd shipping address if the customer have different shipping address from billing address. It won't even let you exit from that page. Do you have any further solution? Thanks Sharon OK, I've played with it a bit and found a quick solution. This probably only effects those who have migrated customer data from an older version of the store. In MySQL set the default value for the address_book_id field in the address_book table to 0 instead of 1 and the addresses will appear for new customers. If you have already received orders where there are no customer details you will have to bite the bullet and enter them manually directly into the database. Remeber that although no address details have been entered into the orders they do exist in the customer records in the database. <{POST_SNAPBACK}> Link to comment Share on other sites More sharing options...
scandic_outlet Posted October 9, 2006 Share Posted October 9, 2006 Did you check if you have imported your SQL databse correctly. We got the same result when we moved our Database, and for some reason, the customers_info table was not imported correctly. Best regards GroundStyle.com Dedicated OsCommerce user. 2011 will be the return of OsC Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.