Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How Do I Assign a SQL Database Entry to a Variable


tahuti

Recommended Posts

Posted

I would sure appreciate someone in the know throwing out a quick answer to my problem.

 

I know I should be able to figure this out, but after a day of trial and error using various techniques from the PHP site and the MYSQL site I still can't figure this one out.....

 

All I want to do....and yes I'm flogging myself for my lack of ability to resolve this easy problem......

 

IN THE OSC SQL TABLE "CONFIGURATION": All I want to do is assign the value associated with SHIPPING_ORIGIN_ZIP (Which is the configuration_key) to a variable for use in OSC....

 

I tried a bunch of thing but this one made the most sense but didn't work:

 

I tried adding $zipcode = SHIPPING_ORIGIN_ZIP (maybe I need to put "set" in front ?) above the following code and declared $zipcode as a global variable at the top of the ups.php shipping module and tried to call the variable from the ups line that reads:

 

// class methods
   function quote($method = '') {
     global $HTTP_POST_VARS, $order, $shipping_weight, $shipping_num_boxes;

     if ( (tep_not_null($method)) && (isset($this->types[$method])) ) {
       $prod = $method;
     } else if ($order->delivery['country']['iso_code_2'] == 'CA') {
           $prod = 'STD';
     } else {
       $prod = 'GNDRES';
     }

     if ($method) $this->_upsAction('3'); // return a single quote

     $this->_upsProduct($prod);

     $country_name = tep_get_countries(SHIPPING_ORIGIN_COUNTRY, true);
     $this->_upsOrigin(SHIPPING_ORIGIN_ZIP, $country_name['countries_iso_code_2']);

 

CHANGING THE LAST LINE TO READ:

 

    $this->_upsOrigin($zipcode, $country_name['countries_iso_code_2']);

 

But that was obviously too simple.....

 

There must be a different way I need to pull the info out of the SQL table and assign it to the variable?????

 

Do I need to call it by the confguration_id?

 

Thanks for any help.....

 

Sorry to have to ask.....

Posted

Would help if you explained how you wish to use the variable - if it doesn't vary then you don't need a variable - simply SHIPPING_ORIGIN_ZIP will do :P

 

But, you pretty much had it - assign it like this:

 

<?php $zipcode = SHIPPING_ORIGIN_ZIP; ?>

 

Print it like this:

 

<?php echo $zipcode; ?>

 

but then, this also works anywhere you need it:

 

<?php echo SHIPPING_ORIGIN_ZIP; ?>

 

Matti

Posted

I don't have time to try right this second......

 

But I bet I wasn't including the ";" after the $zipcode= line

 

Thanks.....

Posted

Yep...that was it......Thanks so much.....I should have caught that one.....

 

Amazing how important a little ";" or "}" can be........haha

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...