Guest Posted December 19, 2003 Posted December 19, 2003 Can someone Help with this section of code. I am trying to insert a custom field that should return the affiliates code to my paypal.cgi ipn file. I am unfamiliar with PHP the line I am haveing the problem with is in the bold how should it read to call the variable $affiliate? function process_button() { global $order, $currencies, $currency; if (MODULE_PAYMENT_PAYPAL_CURRENCY == 'Selected Currency') { $my_currency = $currency; } else { $my_currency = substr(MODULE_PAYMENT_PAYPAL_CURRENCY, 5); } if (!in_array($my_currency, array('CAD', 'EUR', 'GBP', 'JPY', 'USD'))) { $my_currency = 'USD'; } // This php code will fetch the referring affiliate's username. // It returns: // $affiliate - the referring affiliate's username // Make the database connection $connection = mysql_connect("localhost","usernamexxx","xxxxx") or die ("Couldn't connect to the database"); $db2 = mysql_select_db("ufindsavings_com", $connection) or die ("Couldn't select database"); // Search for the cookie first $affiliate = $HTTP_COOKIE_VARS["mycookie"]; // If no cookie, search for the IP address if (!$affiliate) { $ip = getenv("REMOTE_ADDR"); $sql="SELECT * FROM ua_hits WHERE Ip like '$ip'"; $sql_result = mysql_query($sql,$connection) or die ("Couldn't execute query"); while ($row = mysql_fetch_array($sql_result)) { $affiliate = $row["Id"]; }} $process_button_string = tep_draw_hidden_field('cmd', '_xclick') . tep_draw_hidden_field('custom', $affiliate) . tep_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_ID) . tep_draw_hidden_field('item_name', STORE_NAME) . tep_draw_hidden_field('amount', number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->get_value ($my_currency), $currencies->get_decimal_places($my_currency))) . tep_draw_hidden_field('image_url', 'https://www.mysitepicure.com/images/cart.gif') . tep_draw_hidden_field('shipping', number_format($order- >info['shipping_cost'] * $currencies->get_value($my_currency), $currencies- >get_decimal_places($my_currency))) . tep_draw_hidden_field('currency_code', $my_currency) . tep_draw_hidden_field('return', tep_href_link (FILENAME_CHECKOUT_PROCESS, '', 'SSL')) . tep_draw_hidden_field('cancel_return', tep_href_link (FILENAME_CHECKOUT_PAYMENT, '', 'SSL')); return $process_button_string; Thank You. :)
Recommended Posts
Archived
This topic is now archived and is closed to further replies.