Solved

php currency converter

Posted on 2002-07-17
20
634 Views
Last Modified: 2008-02-01
Most currency converters seem to be written in PHP.

I have no experience in this area - anyone know where I can get a script - not one of those linked to another site: ie; hosted somewhere else.

I want to put the script on my server.
0
Comment
Question by:bankle
  • 7
  • 6
  • 4
  • +2
20 Comments
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
Having a script to offer clients the conversions is fine, but where do you intend to get the actual exchange rates from?

You will probably find that you will need to buy that service from someone. Or manually update it once a hour/day/week/etc.

0
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
Alternatively, you can use a script to grab the current rates from another website (this may be naughty and prohibited in some way - not sure).

There is a script at ...

http://www.hotscripts.com/Detailed/11874.html

but I've not used it, but I cannot get a download.

Also ...

http://skintech.skinbase.org/xchanger/install.php

which seems to allow you to be sent updates of the new rates.

Richard.
0
 

Author Comment

by:bankle
Comment Utility
I have subscribed to an exchange rate update service.

I need a currency converter script. That is the question.

Not exchange rates.
0
 
LVL 5

Expert Comment

by:dkjariwala
Comment Utility
So wat does that service provide you ?

I mean in which form it provides the latest,updated exchange rates ?

JD
0
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
The second script seems to offer what you want. It asks how much in 1 and gives you the amount in another.

0
 

Author Comment

by:bankle
Comment Utility
I am having trouble installing it.

I found a free php hosting service.

I uploaded the files to a folder "calc" and followed the rest of the instructions, but got all sorts of errors. No idea what I am doing wrong - no experience with php.
0
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
What sort of errors?
0
 
LVL 5

Expert Comment

by:dkjariwala
Comment Utility
Exactly.

Can you give us error messages which you got ?
JD
0
 

Author Comment

by:bankle
Comment Utility
Here is URL of "install.php"

http://auntypizza.port5.com/calc/install.php
There is an error message at the top.

When I put in my username and password, I get this . . .

Warning: MySQL Connection Failed: Access denied for user: 'auntypiz@localhost' (Using password: YES) in /host/a/u/n/p/o/r/auntypizza.port5.com/calc/install.php on line 40
Could not connect

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 5

Expert Comment

by:dkjariwala
Comment Utility
The problem is that the parameters you supplied to mysql_connect() are not ok.

The username/password combination is wrong. Verify them with your mysql admin and it will be done.

JD
0
 

Author Comment

by:bankle
Comment Utility
Remember - I know NOTHING about PHP - so I don't know what
"mysql_connect()" means . . . I put in the username I used to register at this site, then they sent me a password.

I registered at http://www.portland.co.uk/

I just added the hosted database, but it still doesn't work?

 
0
 
LVL 5

Expert Comment

by:dkjariwala
Comment Utility
Have you got any database hostname, username and password for your hosted database ?

Put up install.php code here,i tell you where to put those details.

JD
0
 

Author Comment

by:bankle
Comment Utility
I have sent an email requesting database hostname, username and password for my hosted database.



========================================================

install.php code is:

<HTML>
<HEAD>
 <TITLE>X-Changer Installation Script</TITLE>
 <LINK REL="stylesheet" TYPE="text/css" HREF="MojStil.css">
</HEAD>
<BODY>

<?
extract ($HTTP_POST_VARS, EXTR_PREFIX_SAME,"wddx");
extract ($HTTP_GET_VARS, EXTR_PREFIX_SAME,"wddx");
if(empty($action))
{
?>
 <TABLE CLASS=MojText>
  <TR>
   <TD>
    <FORM ACTION="<?echo $PHP_SELF;?>" METHOD="POST">
     Server:<BR>
     <INPUT TYPE="text" NAME="db_server" value="localhost" SIZE=40><BR>
     Username:<BR>
     <INPUT TYPE="text" NAME="db_uname" value="" SIZE=40><BR>
     Password:<BR>
     <INPUT TYPE="password" NAME="db_pass" value="" SIZE=40><BR>
     Database Name:<BR>
     <INPUT TYPE="text" NAME="db_name" value="xchanger" SIZE=40><BR>
     <INPUT TYPE="hidden" NAME="action" value="step2" SIZE=40><BR>
     <INPUT TYPE="Submit">
    </FORM>
     FILE <B>db.inc.php</B> MUST HAVE PERMISSION SET TO MODE 666 !!!<BR>
   </TD>
  </TR>
 </TABLE>
<?
}
?>

<?
if($action == "step2")
{
 $link = mysql_connect($db_server, $db_uname, $db_pass) or die("Could not connect");

 if(!mysql_select_db($db_name))
 {
  mysql_create_db("$db_name");
  mysql_select_db($db_name);
 }
 
?>
 <TABLE CLASS=MojText>
  <TR>
   <TD>
    <FORM ACTION="<?echo $PHP_SELF;?>" METHOD="POST">
     Rates table name:<BR>
     <INPUT TYPE="text" NAME="db_rates" value="rates" SIZE=40><BR>
     Updates table name:<BR>
     <INPUT TYPE="text" NAME="db_updates" value="updates" SIZE=40><BR>
     <BR>
     Interval for updating rates [min](it should be at least 120 min):<BR>
     <INPUT TYPE="text" NAME="interval" value="120" SIZE=40><BR>
     <BR>
     <INPUT TYPE="hidden" NAME="action" value="step3" SIZE=40>
     <INPUT TYPE="hidden" NAME="db_server" value="<?echo $db_server;?>">
     <INPUT TYPE="hidden" NAME="db_uname" value="<?echo $db_uname;?>">
     <INPUT TYPE="hidden" NAME="db_pass" value="<?echo $db_pass;?>" >
     <INPUT TYPE="hidden" NAME="db_name" value="<?echo $db_name;?>">

     <INPUT TYPE="Submit">
    </FORM>
   </TD>
  </TR>
 </TABLE>
<?
 mysql_close($link);
}
?>

<?
if($action == "step3")
{
 $link = mysql_connect($db_server, $db_uname, $db_pass) or die("Could not connect");
 mysql_select_db($db_name);
 echo "Creating Tables:<BR>";
 echo "$db_rates ...<BR>";
 mysql_query("CREATE TABLE $db_rates (id int(11) NOT NULL auto_increment,ime tinytext NOT NULL,valuta tinytext NOT NULL,  vrednost float(8,2) NOT NULL default '0.00',sifra tinytext NOT NULL,KEY id (id)) TYPE=MyISAM;");
 echo mysql_error()."<BR>";
 echo "$db_updates ...<BR>";
 mysql_query("CREATE TABLE $db_updates (last_update datetime default NULL) TYPE=MyISAM;");
 echo mysql_error()."<BR>";

 mysql_query("DELETE FROM $db_rates;");

 echo "<BR>Filling Data into Tables:<BR>";
 mysql_query("INSERT INTO $db_rates VALUES (1, 'United States', 'U.S. Dollar', '1.00', 'U.S. Dollar ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (2, 'Argentina', 'Argentinian Peso', '3.61', 'Argentine Peso ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (3, 'Australia', 'Australian Dollar ', '1.77', 'Australian Dollar ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (4, 'Bahamas', 'Bahamian Dollar ', '1.00', 'Bahamian Dollar ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (5, 'Brazil', 'Brazilian Real ', '2.69', 'Brazilian Real ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (6, 'Chile', 'Chilean Peso ', '675.46', 'Chilean Peso ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (7, 'China', 'Chinese Renminbi ', '8.28', 'Chinese Renminbi ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (8, 'Colombia', 'Colombian Peso ', '2397.20', 'Colombian Peso ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (9, 'Croatia', 'Croatian Kuna', '7.66', 'Croatian Kuna ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (10, 'Czech. Republic', 'Czech. Republic Koruna ', '31.89', 'Czech. Republic Koruna ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (11, 'Denmark', 'Danish Krone ', '7.79', 'Danish Krone ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (12, 'European Union', 'EURO', '1.05', 'European Monetary Union EURO');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (13, 'Fiji', 'Fiji Dollar ', '2.12', 'Fiji Dollar ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (14, 'Ghana', 'Ghanaian Cedi ', '7945.36', 'Ghanaian Cedi ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (15, 'Honduras', 'Honduran Lempira ', '16.40', 'Honduran Lempira ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (16, 'Hong Kong', 'Hong Kong Dollar', '7.80', 'Hong Kong Dollar ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (17, 'Hungary', 'Hungarian Forint ', '254.69', 'Hungarian Forint ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (18, 'Iceland', 'Icelandic Krona ', '89.30', 'Icelandic Krona ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (19, 'India', 'Indian Rupee', '48.89', 'Indian Rupee ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (20, 'Indonesia', 'Indonesian Rupiah ', '8611.17', 'Indonesian Rupiah ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (21, 'Israel', 'Israeli New Shekel ', '4.96', 'Israeli New Shekel ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (22, 'Japan', 'Japanese Yen', '124.06', 'Japanese Yen ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (23, 'Malaysia', 'Malaysian Ringgit ', '3.80', 'Malaysian Ringgit ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (24, 'Mexico', 'New Peso', '9.69', 'Mexican New Peso ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (25, 'Morocco', 'Moroccan Dirham ', '10.94', 'Moroccan Dirham ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (26, 'Myanmar (Burma) ', 'Myanmar Kyat ', '6.54', 'Myanmar (Burma) Kyat ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (27, 'N. Antilles', 'Neth. Antilles Guilder ', '1.78', 'Neth. Antilles Guilder ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (28, 'New Zealand', 'New Zealand Dollar', '2.05', 'New Zealand Dollar ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (29, 'Norway', 'Norwege Krone', '7.72', 'Norwegian Krone ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (30, 'Pakistan', 'Pakistan Rupee ', '60.12', 'Pakistan Rupee ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (31, 'Panama', 'Panamanian Balboa ', '1.00', 'Panamanian Balboa ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (32, 'Peru', 'Peruvian New Sol', '3.47', 'Peruvian New Sol ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (33, 'Philippine', 'Philippine Peso ', '50.03', 'Philippine Peso ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (34, 'Poland', 'Polish Zloty', '4.02', 'Polish Zloty ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (35, 'Russian', 'Russian Rouble', '31.45', 'Russian Rouble ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (36, 'Singapore', 'Singapore Dollar ', '1.79', 'Singapore Dollar ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (37, 'Slovakia', 'Koruna', '46.46', 'Slovak Koruna ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (38, 'Slovenia', 'Slovenian Tolar', '237.03', 'Slovenian Tolar ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (39, 'South Africa', 'South African Rand', '10.25', 'South African Rand ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (40, 'South Korea', 'South Korean Won', '1230.17', 'South Korean Won ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (41, 'Sri Lanka', 'Sri Lanka Rupee ', '96.22', 'Sri Lanka Rupee ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (42, 'Sweden', 'Swedish Krona', '9.50', 'Swedish Krona ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (43, 'Switzerland', 'Swiss Franc', '1.54', 'Swiss Franc ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (44, 'Taiwan', 'Taiwanese New Dollar ', '33.95', 'Taiwanese New Dollar ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (45, 'Thailand', 'Thailand Thai Baht ', '42.11', 'Thai Baht ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (46, 'Trinidad & Tobago', 'Trinidad & Tobago Dollar', '6.11', 'Trinidad & Tobago Dollar ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (47, 'Tunisia', 'Tunisisan Dinar', '1.42', 'Tunisian Dinar ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (48, 'Turkey', 'Turkish Lira', '154.50', 'Turkish Lira (2) ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (49, 'Great Britain', 'Pound Sterling ', '0.67', 'Pound Sterling ');");
 echo ".";
 mysql_query("INSERT INTO $db_rates VALUES (50, 'Venezuela', 'Bolivar ', '1250.12', 'Venezuelan Bolivar ');");
 echo ".";
 mysql_query("INSERT INTO $db_updates VALUES ('2002-06-20 09:00:00');");
 echo ".<BR>Done.<BR>";


 $fp = fopen("db.inc.php","w");
 fwrite($fp,"<?\n");
 fwrite($fp,"\$db_server  = \"$db_server\";\n");
 fwrite($fp,"\$db_uname   = \"$db_uname\";\n");
 fwrite($fp,"\$db_pass    = \"$db_pass\";\n");
 fwrite($fp,"\$db_name    = \"$db_name\";\n");
 fwrite($fp,"\$db_rates   = \"$db_rates\";\n");
 fwrite($fp,"\$db_updates = \"$db_updates\";\n");
 fwrite($fp,"\$interval   = \"$interval\";\n");

 fwrite($fp,"?>");
 fclose($fp);

 mysql_close($link);
}
?>

</BODY>
</HTML>
0
 
LVL 5

Expert Comment

by:dkjariwala
Comment Utility
Okie,

See when you run the script without any parameters,

i mean when you just call the script from browser,

it shall ask you db host, user name and password. Enter the values which you get and you shall be through !!!

JD
0
 
LVL 8

Expert Comment

by:GEM100
Comment Utility
Yep...
0
 

Author Comment

by:bankle
Comment Utility
Do you mean this link:

http://auntypizza.port5.com/calc/install.php

???????

There is still an error message at the top:

"Warning: Wrong datatype in call to extract() in /host/a/u/n/p/o/r/auntypizza.port5.com/calc/install.php on line 9"

I don;t know anything about PHP so can you be more clear.

Thanks
0
 
LVL 5

Expert Comment

by:dkjariwala
Comment Utility
Which version of PHP you are using ?

Put followin code in test.php and and tell me the version.


<?php

//test.php

phpinfo();

?>

Seems like $HTTP_GET_VARS are not available in the version of PHP you are using.

JD
0
 

Author Comment

by:bankle
Comment Utility
I made a test.php page - it is version 4.

Here is URL to test.php

http://auntypizza.port5.com/calc/test.php
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
Comment Utility
PAQ'd and points refunded.

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now