Author Topic: $_REQUEST is not working  (Read 1368 times)

itoroyal

  • Beginner
  • *
  • Posts: 1
$_REQUEST is not working
« on: July 30, 2009, 12:29:02 pm »
The problem is that when i'm adding new ship carrier in Virtuemart, it is saved in database without shipping_carrier_id (by default 'null' in database).

So i've looked inside the function 'add' in ps_shipping.php in folder \administrator\components\com_virtuemart\html.
Code: [Select]
function add(&$d) {

$ps_vendor_id = $_SESSION["ps_vendor_id"];
$db = new ps_DB;
$timestamp = time();

if (!$this->validate_add($d)) {
return False;
}
   
$fields = array( 'shipping_carrier_name' => vmGet($d, 'shipping_carrier_name'),
'shipping_carrier_list_order' => (int)$d['shipping_carrier_list_order']);
$db->buildQuery('INSERT', '#__{vm}_shipping_carrier', $fields );

$db->query();

$_REQUEST['shipping_carrier_id'] = $db->last_insert_id();

return True;

}

untill $db->query() everything is fine, but $_REQUEST['shipping_carrier_id'] = $db->last_insert_id() seems not working.

So i've changed my code by adding the shipping_carrier_id manually as follows
Code: [Select]
function add(&$d) {

$ps_vendor_id = $_SESSION["ps_vendor_id"];
$db = new ps_DB;
$timestamp = time();

if (!$this->validate_add($d)) {
return False;
}
   
[color=red] $q = "SELECT shipping_carrier_id FROM #__{vm}_shipping_carrier";
// Get list of Values
$db->query($q);

$a=sizeof($db->record);[/color]

$fields = array( 'shipping_carrier_name' => vmGet($d, 'shipping_carrier_name'),
'shipping_carrier_list_order' => (int)$d['shipping_carrier_list_order'],
[color=red]'shipping_carrier_id' => $a+1[/color]);
$db->buildQuery('INSERT', '#__{vm}_shipping_carrier', $fields );

$db->query();
//$a=$db->last_insert_id();
//$_REQUEST['shipping_carrier_id'] = $db->last_insert_id();

return True;

}

It now works. shipping_carrier_id is saved to database.
It is supposed to be something wrong with $_REQUEST. There are 100+ $_REQUEST call in virtuemart. I have to work out the problem.
Is anyone has idea to this problem?

My configurations:
XAMPP+ PHP Version 5.2.9 + MySQL 5+

Many thanks

Ito