Jump to content

rippergr

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by rippergr

  1. Ok I got it. It was a stupid error in database . Your code is working great. Thanks for your help
  2. The code seems ok but I don't know why it doesnt work in mt database. Is there any way so I can debug this to see what is going on in every line? Maybe with a php code?
  3. Let me give you all the tables structure maybe I didnt explain it very well. I attach the two tables maybe this will help. CREATE TABLE IF NOT EXISTS `jos_vm_user_info` ( `user_info_id` varchar(32) NOT NULL DEFAULT '', `user_id` int(11) NOT NULL DEFAULT '0', `address_type` char(2) DEFAULT NULL, `address_type_name` varchar(32) DEFAULT NULL, `company` varchar(64) DEFAULT NULL, `title` varchar(32) DEFAULT NULL, `last_name` varchar(32) DEFAULT NULL, `first_name` varchar(32) DEFAULT NULL, `middle_name` varchar(32) DEFAULT NULL, `phone_1` varchar(32) DEFAULT NULL, `phone_2` varchar(32) DEFAULT NULL, `fax` varchar(32) DEFAULT NULL, `address_1` varchar(64) NOT NULL DEFAULT '', `address_2` varchar(64) DEFAULT NULL, `city` varchar(32) NOT NULL DEFAULT '', `state` varchar(32) NOT NULL DEFAULT '', `country` varchar(32) NOT NULL DEFAULT 'US', `zip` varchar(32) NOT NULL DEFAULT '', `user_email` varchar(255) DEFAULT NULL, `extra_field_1` varchar(255) DEFAULT NULL, `extra_field_2` varchar(255) DEFAULT NULL, `extra_field_3` varchar(255) DEFAULT NULL, `extra_field_4` char(1) DEFAULT NULL, `extra_field_5` char(1) DEFAULT NULL, `cdate` int(11) DEFAULT NULL, `mdate` int(11) DEFAULT NULL, `perms` varchar(40) NOT NULL DEFAULT 'shopper', `bank_account_nr` varchar(32) NOT NULL DEFAULT '', `bank_name` varchar(32) NOT NULL DEFAULT '', `bank_sort_code` varchar(16) NOT NULL DEFAULT '', `bank_iban` varchar(64) NOT NULL DEFAULT '', `bank_account_holder` varchar(48) NOT NULL DEFAULT '', `bank_account_type` enum('Checking','Business Checking','Savings') NOT NULL DEFAULT 'Checking', PRIMARY KEY (`user_info_id`), KEY `idx_user_info_user_id` (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Customer Information, BT = BillTo and ST = ShipTo'; and CREATE TABLE IF NOT EXISTS `jos_users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL DEFAULT '', `username` varchar(150) NOT NULL DEFAULT '', `email` varchar(100) NOT NULL DEFAULT '', `password` varchar(100) NOT NULL DEFAULT '', `usertype` varchar(25) NOT NULL DEFAULT '', `block` tinyint(4) NOT NULL DEFAULT '0', `sendEmail` tinyint(4) DEFAULT '0', `gid` tinyint(3) unsigned NOT NULL DEFAULT '1', `registerDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `lastvisitDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `activation` varchar(100) NOT NULL DEFAULT '', `params` text NOT NULL, PRIMARY KEY (`id`), KEY `usertype` (`usertype`), KEY `idx_name` (`name`), KEY `gid_block` (`gid`,`block`), KEY `username` (`username`), KEY `email` (`email`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1798 ;
  4. I am using wamp and mysql . I am writing code with simple editor and the data I wan tis from virtuemart tables in joomla.
  5. Oh, I didn't see that those two queries were from two different tables. No matter, you can still run just one query. I'm just not sure of the exact syntax. I'll post back shortly with a solution. EDIT: Here you go UPDATE jos_vm_user_info AS i SET i.first_name = (SELECT u.name FROM jos_users AS u WHERE u.id = i.user_id) Thanks. This code works but it only fills the last row . I have almost 1000 rows .
  6. What do you mean what application I am using? If you mean what application is running is joomla and the tables I am trying to get is from virtuemart. both are using mysql
  7. Thanks for your reply Can you tell me how can I get the =name which is in jos_users table field name
  8. Hello I have the following code <?php // STORE DATABASE VARIABLES $hostname_cnConnection = "localhost"; $database_cnConnection = "tekou"; $username_cnConnection = "root"; $password_cnConnection = "1234"; $cnConnection = mysql_pconnect($hostname_cnConnection, $username_cnConnection, $password_cnConnection); mysql_set_charset('utf8',$cnConnection); // CONNECT TO DATABASE mysql_select_db($database_cnConnection, $cnConnection); $data = mysql_query("SELECT * from jos_users") or die(mysql_error()); // Print "<table border cellpadding=3>"; while($info = mysql_fetch_array( $data )) { // echo $info['id']; $prod_id=$info['id'] ; // echo "Product ID " .$prod_id; //Show Product Id mysql_query("UPDATE jos_vm_user_info SET first_name = '".$info['name']." WHERE user_id = ".$info['id']) or die(mysql_error()); } echo $info['id']; ?> I want to read every $name and update in jos_vm_user_info the first_name but I think I have error in code because nothing happens. I quess that .$info['id'] doesnt return a single number but all numbers but I dont know how to fix it. Please someone to help me.
  9. Hello all I am triyng to get all products from virtuemart and export them as xml I am stuck in the part that I must export all the path of the category. The category should be returning in function GetCategoryPath($product_id) in the code that I will give below. Instead I have an error Fatal error: Class 'JFactory' not found in C:\wamp\www\xml.php on line 71 I took this code from another script that does this job but I can use it function GetCategoryPath($product_id) { $db = JFactory::getDBO(); $result = mysql_query("SELECT #__vm_product.product_id, #__vm_product.product_parent_id, category_name,#__vm_category_xref.category_parent_id " ."FROM #__vm_category, #__vm_product, #__vm_product_category_xref,#__vm_category_xref " ."WHERE #__vm_product.product_id='".$product_id."' " ."AND #__vm_category_xref.category_child_id=#__vm_category.category_id " ."AND #__vm_category_xref.category_child_id = #__vm_product_category_xref.category_id " ."AND #__vm_product.product_id = #__vm_product_category_xref.product_id"); $db->setQuery($q); $rows = $db->loadObjectList(); echo $result; $k = 1; $category_path = ""; foreach ($rows as $row) { $category_name = Array(); /** Check for product or item **/ if ( $row->category_name ) { $category_parent_id = $row->category_parent_id; $category_name[] = $row->category_name; } else { /** must be an item * So let's search for the category path of the * parent product **/ $q = "SELECT product_parent_id FROM #__vm_product WHERE product_id='".$product_id."'"; $db->setQuery($q); $ppi = $db->loadResult(); $q = "SELECT #__vm_product.product_id, #__vm_product.product_parent_id, category_name,#__vm_category_xref.category_parent_id " ."FROM #__vm_category, #__vm_product, #__vm_product_category_xref,#__vm_category_xref " ."WHERE #__vm_product.product_id='".$ppi."' " ."AND #__vm_category_xref.category_child_id=#__vm_category.category_id " ."AND #__vm_category_xref.category_child_id = #__vm_product_category_xref.category_id " ."AND #__vm_product.product_id = #__vm_product_category_xref.product_id"; $db->setQuery($q); $cat_details = $db->loadObject(); $category_parent_id = $cat_details->category_parent_id; $category_name[] = $cat_details->category_name; } if( $category_parent_id == "") $category_parent_id = "0"; while ($category_parent_id != "0") { $q = "SELECT category_name, category_parent_id " ."FROM #__vm_category, #__vm_category_xref " ."WHERE #__vm_category_xref.category_child_id=#__vm_category.category_id " ."AND #__vm_category.category_id='".$category_parent_id."'"; $db->setQuery($q); $cat_details = $db->loadObject(); $category_parent_id = $cat_details->category_parent_id; $category_name[] = $cat_details->category_name; } if ( sizeof( $category_name ) > 1 ) { for ($i = sizeof($category_name)-1; $i >= 0; $i--) { $category_path .= $category_name[$i]; if( $i >= 1) $category_path .= "/"; } } else $category_path .= $category_name[0]; if( $k++ < sizeof($rows) ) $category_path .= "|"; } return $category_path; } GetCategoryPath('2'); /** * Creates the category path */ function CreateCategoryPath() { $db = JFactory::getDBO(); $catpaths = array(); while (JRequest::getVar('catid') > 0) { $q = "SELECT category_parent_id, category_name FROM #__vm_category_xref x, #__vm_category c WHERE x.category_child_id = c.category_id AND category_child_id = ".JRequest::getVar('catid'); $db->setQuery($q); $path = $db->loadObject(); $catpaths[] = $path->category_name; JRequest::setVar('catid', $path->category_parent_id); } $catpaths = array_reverse($catpaths); $catpath = ''; foreach ($catpaths as $id => $catname) { $catpath .= $catname."/"; } return $catpath = substr($catpath, 0, -1); } If someone could give me a little help I would appreciate it.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.