-
Posts
426 -
Joined
-
Last visited
Everything posted by lingo5
-
Hi, I have this code to retrieve currency exchange rates from the ECB: <?php $XMLContent=file("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"); //the file is updated daily between 2.15 p.m. and 3.00 p.m. CET foreach($XMLContent as $line){ if(preg_match("/currency='([[:alpha:]]+)'/",$line,$currencyCode)){ if(preg_match("/rate='([[:graph:]]+)'/",$line,$rate)){ //Output the value of 1EUR for a currency code echo'1€='.$rate[1].' '.$currencyCode[1].'<br/>'; //-------------------------------------------------- //Here you can add your code for inserting //$rate[1] and $currencyCode[1] into your database //-------------------------------------------------- } } } ?> I have a DB with 2 fields, one is for the exchange rate (rate) and the other for thecurrency name (currencyCode). My problem is that I don't know how to insert the $rate[1] and $currencyCode[1] in my DB. Thanks for your help.
-
Many thanks Little Guy...that worked perfect.
-
Hi, I am using PHP to perform some area calculations. I have created this form to collect the values: <form name="form1" method="post" action="<?php htmlentities($_SERVER['PHP_SELF']); ?>"> <table width="100%" border="0" cellspacing="0" cellpadding="8"> <tr> <td><table width="100%" border="0" cellspacing="0" cellpadding="1"> <tr> <td bgcolor="#666666"><table width="100%" border="0" cellspacing="0" cellpadding="4"> <tr> <td align="center" bgcolor="#3471C6" class="fondoHogartec"><?=CNT_TXT_CALCULATORTITLE?></td> </tr> <tr> <td align="center" bgcolor="#EEEEDD"><label> <span class="CarritoProducto"><?=CNT_TXT_WATERLINE?><br> </span> <input name="waterline" type="text" class="CalculatorFieldTXT" id="waterline" value="<?php echo((isset($_POST["waterline"]))?$_POST["waterline"]:"") ?>"> </label></td> </tr> <tr> <td align="center" bgcolor="#EEEEDD"><label> <span class="CarritoProducto"><?=CNT_TXT_BEAM?></span><br> <input name="beam" type="text" class="CalculatorFieldTXT" id="beam" value="<?php echo((isset($_POST["beam"]))?$_POST["beam"]:"") ?>"> </label></td> </tr> <tr> <td align="center" bgcolor="#EEEEDD"><label> <span class="CarritoProducto"><?=CNT_TXT_DRAUGHT?></span><br> <input name="draught" type="text" class="CalculatorFieldTXT" id="draught" value="<?php echo((isset($_POST["draught"]))?$_POST["draught"]:"") ?>"> </label></td> </tr> <tr> <td align="center" bgcolor="#EEEEDD"><label> <span class="CarritoPrecio"><?=CNT_TXT_SURFACE?><br> </span> <input name="surface" type="text" class="CalculatorFieldTXT" id="surface" value="<?php echo $total_surface ?>" size="10" > </label></td> </tr> <tr> <td align="center" nowrap bgcolor="#EEEEDD"><label class="CarritoPrecio"><?=CNT_TXT_TOTALCANS?><br> </label> <input name="cans_needed_2coats" type="text" class="CalculatorFieldTXT" id="cans_needed_2coats" value="<?php echo $total_cans ?>"> <br></td> </tr> <tr> <td align="center" nowrap bgcolor="#EEEEDD"><table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td colspan="3" align="center" class="TitulosTXT2"><?=CNT_TXT_KEELTYPE?></td> </tr> <tr> <td align="center" class="TitulosTXT2"><label> <input type="submit" name="keel_type" id="keel_type" value="<?=CNT_TXT_LONG?>"> </label></td> <td align="center"><input type="submit" name="keel_type" id="keel_type" value="<?=CNT_TXT_BILGE?>"></td> <td align="center"><input type="submit" name="keel_type" id="keel_type" value="<?=CNT_TXT_FIN?>"></td> </form> and this is the PHP to perform the calculations: // INICIATE CALCULATOR $keeltype = $_POST["keel_type"]; $waterline_length = $_POST["waterline"]; $beam = $_POST["beam"]; $draught = $_POST["draught"]; if ($keeltype == CNT_TXT_LONG) { $total_surface = $waterline_length*($beam+$draught) ; } if ($keeltype == CNT_TXT_BILGE) { $total_surface = ($waterline_length*($beam+$draught))* 0.75 ; } if ($keeltype == CNT_TXT_FIN) { $total_surface = ($waterline_length*($beam+$draught))* 0.50 ; } $total_cans = $total_surface / 25 ; // END CALCULATOR It works fine when the values entered in the form contain decimals separated by "." but it doesn't calculate properly when the decimals are separated by a comma. Please help. Thanks.
-
Thanks all for your help...I've tried all your suggestions and they all work!!!!... Pikachu your solution kind of rules....
-
Thanks Muddy, I have tried with the else before the opening brace like so... <?php if ($_SESSION['session_idioma'])=="eng" { echo '<a href="preordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; } else { echo '<a href="ordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; }?> ..still no luck. ayKay, tried your suggestion also but same blank page pops up...
-
Hi, i,m trying to echo a "a href" based on the language session of my page like this: ?php if ($_SESSION['session_idioma'])=="eng" { echo '<a href="preordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; } { else echo '<a href="ordering.php"><img src="img/top_banner_'.$_SESSION['session_idioma'].'.jpg" width="744" height="182"></a>'; }?> but I'm getting a blank page wit no errors...must be a syntax error that I can't spot...
-
Works great!!!!!...Thanks a lot Muddy. Thanks everybody.
-
Thanks Muddy...I will try this after lunch!!!...
-
Thanks Muddy, where would I put that code in my query?...something like this? mysql_select_db($database_MySQLconnect, $MySQLconnect); $query_clientes_RS = sprintf("SELECT * FROM t_clientes WHERE id_cliente = %s AND owner_username= '$ownerusername'", GetSQLValueString($colname_clientes_RS, "int")); $clientes_RS = mysql_query($query_clientes_RS, $MySQLconnect) or die(mysql_error()); $row_clientes_RS = mysql_fetch_assoc($clientes_RS); $totalRows_clientes_RS = mysql_num_rows($clientes_RS); if mysql_num_rows($clientes_RS) < 1 { echo "ooooooops"; }
-
Thanks a lot Pikachu...i have added a new owner_username column to the database that stores the login username. I have then created a query that pulls a client record from the dB acording to the owner_username: $query_clientes_RS = sprintf("SELECT * FROM t_clientes WHERE id_cliente = %s AND owner_username= '$ownerusername'", $clientes_RS = mysql_query($query_clientes_RS, $MySQLconnect) or die(mysql_error()); ..and it works perfect. I have tried changing manually the client id passed in the URL to a client id belonging to a different user and by doing this a blank record is shown..which is perfect to test that the system is working BUT....now I would like to show a warning message instead of a blank record when this happens...is this something thatcan be done easily or is it something complicated? Thanks again
-
Thanks Pikachu. How would I include the user session variable in the query?...would it be something like this? SELECT FROM mytable WHERE id_cliente=passed-url-value AND user_session = $_SESSSION['my_user_session']
-
Is this possible at all?. Why is the session $_session['id_cliente'] not passing the values of each client and just the value of the first client of the list instead? Please, I need to see the light. Thanks
-
OK, the login process I have sorted, my problem is that I want each user to be able to: 1. see his clients only 2. update these clients Step 1 I have achieved by selecting those clients linked up to the user's login name by using a username session. Now, once I've pulled up the list of clients for a given user, I need to be able to edit them by clicking on them and opening them in the update page. I want to do this without appending the id_cliente to the url for obvious reasons. So what I need to do is to create a session that gets the id_cliente for each client on the client list and pass it on to the update page. ...I'm all confused now
-
OK, I'm a bit confused now... I have created a session after the query in my main page like this: mysql_select_db($database_MySQLconnect, $MySQLconnect); $query_clientes_RS = sprintf("SELECT * FROM t_clientes WHERE cliente_isclientOf = %s", GetSQLValueString($colname_clientes_RS, "text")); $query_limit_clientes_RS = sprintf("%s LIMIT %d, %d", $query_clientes_RS, $startRow_clientes_RS, $maxRows_clientes_RS); $clientes_RS = mysql_query($query_limit_clientes_RS, $MySQLconnect) or die(mysql_error()); $row_clientes_RS = mysql_fetch_assoc($clientes_RS); session_start(); $_SESSION["idCliente"] = $row_clientes_RS['id_cliente'];//creamos sesion id para que no se vea en la url this should get the client id for each client right Then I'm linking each client on the list to the update page like this: <a href="DIST_clientes_update.php At the top of the update page I have this: session_start(); $idCliente=$_SESSION["idCliente"]; My update query is like this: ysql_select_db($database_MySQLconnect, $MySQLconnect); $query_clientes_RS = sprintf("SELECT * FROM t_clientes WHERE id_cliente = $idCliente", GetSQLValueString($colname_clientes_RS, "int")); $clientes_RS = mysql_query($query_clientes_RS, $MySQLconnect) or die(mysql_error()); $row_clientes_RS = mysql_fetch_assoc($clientes_RS); $totalRows_clientes_RS = mysql_num_rows($clientes_RS); ..but all I get on the update page is the first client from the list no matter on which client from the list I click....
-
sorry Pikachu, is this what you mean? <a href="DIST_clientes_update.php<?php echo $_SESSION["idCliente"];?>
-
Hi, I have a user/password protected page that displays a list of clients. When clicking on them you're redirected to the client record update page. This is how I am linking to taht page now: <a href="DIST_clientes_update.php?id_cliente=<?php echo $row_clients_RS['id_cliente']; ?> The problem with this is that the client id is appended to the url and so if the user chnges it will be able to access records from a different user...and I dont want that. So I have created a session: $_SESSION["idCliente"] = $row_clients_RS['id_cliente']; but how do I pass it to the update page without showing in the url? Thanks
-
thanks Pikachu, I'm loking at that.
-
Thanks Peter_anderson, but by doing that styles are not applied to te email. I would like to be able to send a styled message using my own style sheet. How can I do that?...
-
I have one more question about this, can I insert html code in my email?, I have tried like this: $strMessage = "<table width="450" border="0" cellspacing="0" cellpadding="4"> <tr> <td><span class="NoResultsTXT2">Dear Administrator,</span></td> </tr> <tr> <td><span class="NoResultsTXT2">the following distributor</span></td> </tr> <tr> <td><span class="precioVenta">$row_admin_login_RS['distributor_company_name']</span></td> </tr> <tr> <td><span class="NoResultsTXT2">Has modified his Distributor information record. </span></td> </tr> </table>"; But I get this error "Parse error: syntax error, unexpected T_LNUMBER in /usr/home/eu45antifoul.com/web/distributors/DIST_distributors_update.php on line 216"
-
oh...I see... I was getting a 500 error. Thanks for your help, it works great.
-
Hi, I am trying to insert a variable in the body of an email lik so: $message = "Dear Administrator,\n\nthe following distributor\n\n'.$row_admin_login_RS['distributor_company_name'].'\n\nHas modified his Distributor information record.\n\"; I know it must be a syntax error...but I can't figure it out. Thanks
-
Hi, I have created a login script that creates a user id session from the user email, like so: // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['distributor_email'])) { $loginUsername=$_POST['distributor_email']; $password=$_POST['distributor_password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "DIST_main.php"; $MM_redirectLoginFailed = "index.php?failed=true"; $MM_redirecttoReferrer = false; mysql_select_db($database_MySQLconnect, $MySQLconnect); $LoginRS__query=sprintf("SELECT distributor_email, distributor_password FROM t_distributors WHERE distributor_email=%s AND distributor_password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $MySQLconnect) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); $datetime = date("Y-m-d H:i:s",time()); $query = "UPDATE mydatabase.t_distributors SET distributor_lastlogin= '$datetime' WHERE distributor_email='$loginUsername'"; $result = mysql_query($query) or die(mysql_error()); } else { header("Location: ". $MM_redirectLoginFailed ); } } This works fine, but I need to create one more session to store the Company name of the logged in user. I am struggling to do this as I am new to sessions. Any help much appreciated.
-
Thanks Sergeiss...I think I'm too tired now...I'm more stupid than usual...
-
Hi, I am trying to append a language session like this: $ATC_itemWeight = floatval("".$row_productos_RS['capacidad_'.$_SESSION['session_idioma'].'']; but I get this error Parse error: syntax error, unexpected ';' in /usr/home/mysite.com/web/productos_esp.php on line 121 what am I doing wrong? Thanks
-
thanls premiso, but now none of the 2 fields are enabled.