Hi all,
So near, I think.
Just one error, can anyone see why I should be getting this error;
Notice: Undefined index: id in /var/www/vhosts/mydomain/httpdocs/moneycorp/test.php on line 59
session_start();
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_flightq, $flightq);
$query_flights = "TRUNCATE moneyCorpRates";
$flights = mysql_query($query_flights, $flightq) or die(mysql_error());
$file_handle = fopen("DATA/lgwrates.txt", "rb");
while (!feof($file_handle) ) {
$line_of_text = fgets($file_handle);
$str= $line_of_text;
parse_str($str, $arr);
if (preg_match_all('/([A-Z]{3})(Buy|Sell)=(\d+\.\d+)/', $str, $matches, PREG_SET_ORDER)) {
$data = array();
foreach ($matches as $match) {
$data[$match[1]][$match[2]] = $match[3];
$country = $match[1];
$sellRate = $match[2];
$buyRate = $match[3];
}
$insertSQL = sprintf("INSERT INTO moneyCorpRates (id, country, sellRate, buyRate) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['id'], "int"),
GetSQLValueString($_POST['country'] = $country , "text"),
GetSQLValueString($_POST['sellRate'] = $sellRate , "text"),
GetSQLValueString($_POST['buyRate'] = $buyRate , "text"));
mysql_select_db($database_flightq, $flightq);
$Result1 = mysql_query($insertSQL, $flightq) or die(mysql_error());
}
}
fclose($file_handle);
Thank you all for your help, I learn with each day.