help need to change currency

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

volkswest
Forum Newbie
Posts: 17
Joined: Mon Nov 02, 2009 7:50 am

help need to change currency

Post by volkswest »

hello, I have a website http://www.volkswestads.co.uk but I need to change the currency from $ to £, also on my prices page the currency is in $ and again needs to be £, I have been told that this needs to be changed in mysql, but I know little about PHP, if any one can help or do the job for me I will be willing to pay to put this right, thanks everyone.
Shane
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: help need to change currency

Post by Eric! »

Depends on how is it stored in your database and how it is displayed on your site. Is the sql field DECIMAL, VARCHAR or INTEGER?

Do you want to use dollars anywhere or do you want everything in pounds all the time?
volkswest
Forum Newbie
Posts: 17
Joined: Mon Nov 02, 2009 7:50 am

Re: help need to change currency

Post by volkswest »

Thanks for the reply, like I said in my previous reply I know little about PHP, so I cant answer the following sql field DECIMAL, VARCHAR or INTEGER? Yes I want it just in £ currency, Thanks
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: help need to change currency

Post by pickle »

Are you actually converting the values (as in, something that sells for $1.00 will now be £0.61), or are you just changing the character that goes in front of the numbers?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
volkswest
Forum Newbie
Posts: 17
Joined: Mon Nov 02, 2009 7:50 am

Re: help need to change currency

Post by volkswest »

So excuse my ignorance, but how do I change this please??
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: help need to change currency

Post by pickle »

Please read my post and answer my question.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
volkswest
Forum Newbie
Posts: 17
Joined: Mon Nov 02, 2009 7:50 am

Re: help need to change currency

Post by volkswest »

Sorry about that, I want to be actually converting the values from $ to £ because all payments go through paypal, and the character that goes in front of the numbers aswell from $ to£, thanks
Last edited by volkswest on Mon Nov 02, 2009 12:06 pm, edited 1 time in total.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: help need to change currency

Post by pickle »

First off, I'd strip out the currency character - it shouldn't be in that database field anyway. You *might* be able to do that all in MySQL by doing something like this:

Code: Select all

UPDATE
  `theTable`
SET
  `theCurrencyField` = CAST(`theCurrencyField` AS UNSIGNED)
Then, in another query (though perhaps you could do it all in one query) do some math to convert from U.S. dollars (or any other dollar you've got) to the pound

Code: Select all

UPDATE
  `theTable`
SET
  `theCurrencyField` = `theCurrencyField` * 0.61
* 0.61 is the exchange rate Google reports
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
volkswest
Forum Newbie
Posts: 17
Joined: Mon Nov 02, 2009 7:50 am

Re: help need to change currency

Post by volkswest »

Hi Pickle, Can you do the job for me if I pay you???
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: help need to change currency

Post by pickle »

No. I've given you the information you need to do it yourself. Heck, you can probably just change the field and table names in those queries & it should work.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: help need to change currency

Post by Eric! »

It might be a bit more complicated because the currency denomination being passed to Paypal needs to be set to pounds too. Also there could be code in the site that is doing some conversions between currencies too.

I doubt the currency symbol is in the database, though. It's probably just all numbers as a DECIMAL field, at least if it was done by someone who knows what they are doing.

@volkswest who did this code for you? Why can't you pay them to fix it?
volkswest
Forum Newbie
Posts: 17
Joined: Mon Nov 02, 2009 7:50 am

Re: help need to change currency

Post by volkswest »

Eric,
I bought this from a bloke in the USA, I have emailed him maybe 10 times to ask him about the currency, and the only answer I got is "you will have to change it in the mysql" apart from that he doesnt want to know. All I see in prices.php is $$a1[price]</td>\n</tr>\n"; which I changed to £$a1[price]</td>\n</tr>\n"; and this changed the $ sign on the prices page to the £ symbol, all I need now is to figure out how to change the $ to £ when people check out with paypal.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: help need to change currency

Post by Eric! »

All you have to do is configure paypal to use pounds as your primary currency. I would guess your database is denomination independent and just stores a decimal number.

https://www.paypal.com/cgi-bin/webscr?c ... ro-outside
volkswest
Forum Newbie
Posts: 17
Joined: Mon Nov 02, 2009 7:50 am

Re: help need to change currency

Post by volkswest »

This is the code I have in the payment page, my primary currency is £
I have tried to change the paypal code but nothing works.

Code: Select all

<?
require_once("conn.php");
require_once("includes.php");
 
if(empty($_GET[SelectedPackage]))
{
    header("location:$_SERVER[HTTP_REFERER]?e=1&PaymentGateway=$_GET[PaymentGateway]");
    exit();
}
elseif(empty($_GET[PaymentGateway]))
{
    header("location:$_SERVER[HTTP_REFERER]?e=2&SelectedPackage=$_GET[SelectedPackage]");
    exit();
}
else
{
    if(!empty($_SESSION[AgentID]))
    {
        $MyID = $_SESSION[AgentID];
    }
 
    if(!empty($_SESSION[MemberID]))
    {
        $MyID = $_SESSION[MemberID];
    }
 
    //get the agent details
    $q1 = "select * from class_members where MemberID = '$MyID' ";
    $r1 = mysql_query($q1) or die(mysql_error());
    $a1 = mysql_fetch_array($r1);
 
    //get the price details
    $q2 = "select * from class_prices where PriceID = '$_GET[SelectedPackage]' ";
    $r2 = mysql_query($q2) or die(mysql_error());
    $a2 = mysql_fetch_array($r2);
 
    /*
 
    flags:
 
    r -> renew
 
    n -> new
 
    m -> more
 
    */
 
    if(ereg("renew.php", $_SERVER[HTTP_REFERER]))
    {
        $flag = "r";
        $action = "Renewal";
    }
    elseif(ereg("more.php", $_SERVER[HTTP_REFERER]))
    {
        $flag = "m";
        $action = "Upgrade";
    }
    else
    {
        $flag = "n";
        $action = "Activation";
    }
 
    if($_GET[PaymentGateway] == "paypal")
    {
        header("location:https://www.paypal.com/xclick?business=$aset[PayPalEmail]&item_name=$a2[ads] ads for $a2[days] days&first_name=$a1[FirstName]&last_name=$a1[LastName]&email=$a1[email]&item_number=1&custom=$MyID|$_GET[SelectedPackage]|$flag&amount=$a2[price]&notify_url=http://$_SERVER[HTTP_HOST]".dirname($_SERVER[PHP_SELF])."/notify.php&return=http://$_SERVER[HTTP_HOST]".dirname($_SERVER[PHP_SELF])."/login.php");
 
        exit();
 
    }
    elseif($_GET[PaymentGateway] == "stormpay")
    {
        header("location:https://www.stormpay.com/stormpay/handle_gen.php?generic=1&vendor_email=$aset[sp_vendor_email]&payee_email=$aset[sp_payee_email]&transaction_ref=$MyID|$_GET[SelectedPackage]|$flag&product_name=$a2[ads] ads for $a2[days] days&amount=$a2[price]&require_IPN=1&notify_URL=http://$_SERVER[HTTP_HOST]/sp_notify.php&return_URL=http://$_SERVER[HTTP_HOST]".dirname($_SERVER[PHP_SELF])."/login.php&cancel_URL=http://$_SERVER[HTTP_HOST]".dirname($_SERVER[PHP_SELF])."/cancel.php");
      
        exit();
    }
}
 
?>
Last edited by volkswest on Tue Nov 03, 2009 6:48 am, edited 1 time in total.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: help need to change currency

Post by Eric! »

Please only post code using the proper tags. You can go back and edit your posts,
[syntax=php]Paste Code Here[/syntax]

Who integrated your site with paypal? Do the payments go to your own paypal account? Did the code also configure mysql for you too?
Post Reply